https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91101

--- Comment #3 from Frantisek Sumsal <frantisek at sumsal dot cz> ---
ltrace stastistics:

# WITH sanitizers and detect_stack_use_after_return=1

[vagrant@arch build]$ export
ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1
[vagrant@arch build]$ ltrace -c
build-gcc-9.1.0-sanitizers-tempfiles/test-conf-parser
<...snip...>
==25291==LeakSanitizer has encountered a fatal error.
==25291==HINT: For debugging, try setting environment variable
LSAN_OPTIONS=verbosity=1:log_threads=1
==25291==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
% time     seconds  usecs/call     calls      function
------ ----------- ----------- --------- --------------------
 99.86   28.250721     1661807        17 config_parse
  0.03    0.007281        3640         2 __asan_init
  0.01    0.003920         230        17 log_internal_realm
  0.01    0.003716          50        73 __asan_stack_malloc_0
  0.01    0.002837         166        17 fmkostemp_safe
  0.01    0.002085         122        17 fwrite
  0.01    0.001718         101        17 unlink_tempfilep
  0.01    0.001490          87        17 rewind
  0.00    0.001354          79        17 safe_fclose
  0.00    0.001311          77        17 strlen
  0.00    0.001208          50        24 free
  0.00    0.001191         170         7 config_parse_mode
  0.00    0.000998         142         7 config_parse_unsigned
  0.00    0.000984         140         7 config_parse_path
  0.00    0.000946         135         7 config_parse_int
  0.00    0.000941          52        18 __asan_stack_malloc_3
  0.00    0.000921         102         9 config_parse_iec_size
  0.00    0.000901         128         7 config_parse_sec
  0.00    0.000850          56        15 strcmp
  0.00    0.000850         121         7 config_parse_nsec
  0.00    0.000826          91         9 config_parse_si_size
  0.00    0.000800          47        17 log_get_max_level_realm
  0.00    0.000460         460         1 log_parse_environment_realm
  0.00    0.000381          63         6 config_parse_strv
  0.00    0.000348          49         7 strcmp_ptr
  0.00    0.000336         112         3 config_parse_log_facility
  0.00    0.000314         104         3 config_parse_log_level
  0.00    0.000299          49         6 strv_equal
  0.00    0.000282          56         5 strv_free
  0.00    0.000154         154         1 __asan_unregister_globals
  0.00    0.000109          54         2 config_parse_iec_uint64
  0.00    0.000079          79         1 __asan_register_globals
  0.00    0.000057          57         1 log_open
  0.00    0.000047          47         1 __asan_version_mismatch_check_v8
------ ----------- ----------- --------- --------------------
100.00   28.290715                   382 total


# WITH sanitizers and detect_stack_use_after_return=0

[vagrant@arch build]$ export
ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=0:check_initialization_order=1:strict_init_order=1
[vagrant@arch build]$ ltrace -c
build-gcc-9.1.0-sanitizers-tempfiles/test-conf-parser
<...snip...>
==25301==LeakSanitizer has encountered a fatal error.
==25301==HINT: For debugging, try setting environment variable
LSAN_OPTIONS=verbosity=1:log_threads=1
==25301==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
% time     seconds  usecs/call     calls      function
------ ----------- ----------- --------- --------------------
 98.90    2.914199      171423        17 config_parse
  0.23    0.006749        3374         2 __asan_init
  0.10    0.002973         174        17 log_internal_realm
  0.09    0.002646         155        17 fmkostemp_safe
  0.07    0.002095         123        17 fwrite
  0.05    0.001416          83        17 unlink_tempfilep
  0.05    0.001406          82        17 rewind
  0.04    0.001317          54        24 free
  0.04    0.001257          73        17 strlen
  0.04    0.001225          72        17 safe_fclose
  0.04    0.001060         151         7 config_parse_mode
  0.03    0.000891          52        17 log_get_max_level_realm
  0.03    0.000877          97         9 config_parse_iec_size
  0.03    0.000862          57        15 strcmp
  0.03    0.000851         121         7 config_parse_int
  0.03    0.000846         120         7 config_parse_unsigned
  0.03    0.000841         120         7 config_parse_path
  0.03    0.000838          93         9 config_parse_si_size
  0.02    0.000692          98         7 config_parse_sec
  0.02    0.000679          97         7 config_parse_nsec
  0.01    0.000395         395         1 log_parse_environment_realm
  0.01    0.000364          60         6 config_parse_strv
  0.01    0.000359          51         7 strcmp_ptr
  0.01    0.000324         108         3 config_parse_log_facility
  0.01    0.000309          51         6 strv_equal
  0.01    0.000282          56         5 strv_free
  0.01    0.000266          88         3 config_parse_log_level
  0.01    0.000154         154         1 __asan_unregister_globals
  0.00    0.000109          54         2 config_parse_iec_uint64
  0.00    0.000082          82         1 __asan_register_globals
  0.00    0.000054          54         1 __asan_version_mismatch_check_v8
  0.00    0.000049          49         1 log_open
------ ----------- ----------- --------- --------------------
100.00    2.946467                   291 total


# WITHOUT sanitizers

[vagrant@arch build]$ ltrace -c build-gcc-9.1.0/test-conf-parser
<...snip...>
% time     seconds  usecs/call     calls      function
------ ----------- ----------- --------- --------------------
 97.98    1.259239       74072        17 config_parse
  0.27    0.003530         207        17 log_internal_realm
  0.19    0.002399         141        17 fmkostemp_safe
  0.16    0.002012         118        17 fwrite
  0.13    0.001629          95        17 unlink_tempfilep
  0.12    0.001539          90        17 rewind
  0.10    0.001301          54        24 free
  0.10    0.001274          74        17 strlen
  0.10    0.001225          72        17 safe_fclose
  0.08    0.001057         151         7 config_parse_mode
  0.08    0.001032          60        17 log_get_max_level_realm
  0.07    0.000955         136         7 config_parse_int
  0.07    0.000953         105         9 config_parse_iec_size
  0.07    0.000914         130         7 config_parse_unsigned
  0.07    0.000869          96         9 config_parse_si_size
  0.07    0.000840         120         7 config_parse_nsec
  0.06    0.000792         113         7 config_parse_sec
  0.06    0.000720         102         7 config_parse_path
  0.06    0.000715          47        15 strcmp
  0.03    0.000403          57         7 strcmp_ptr
  0.02    0.000307          51         6 strv_equal
  0.02    0.000292          97         3 config_parse_log_facility
  0.02    0.000290          96         3 config_parse_log_level
  0.02    0.000284          47         6 config_parse_strv
  0.02    0.000250          50         5 strv_free
  0.02    0.000249         249         1 log_parse_environment_realm
  0.01    0.000128          64         2 config_parse_iec_uint64
  0.00    0.000050          50         1 log_open
------ ----------- ----------- --------- --------------------
100.00    1.285248                   286 total

----

For some reason the `config_parse` function (in this particular case) is called
almost 10 times more often with `detect_stack_use_after_return=1` than
withoiut, which is not the case with GCC 8.3.0 (where it is 205089 calls with
`detect_stack_use_after_return=1` versus 192490 without).

Reply via email to