Created attachment 1508981 [details] reproducer Description of problem: symbolized stack traces no longer available when -flto and -fsanitize are used together Version-Release number of selected component (if applicable): devtoolset-8-gcc-8.2.1-3.el7.x86_64 How reproducible: Always Steps to Reproduce: 1. cat stack-buffer-overflow.c int main(int argc, char **argv) { int stack_array[100]; stack_array[1] = 0; return stack_array[argc + 100]; // BOOM } 2. scl enable devtoolset-8 "gcc -g -O2 -flto -fsanitize=address stack-buffer-overflow.c -o KO_dts8_out" ./KO_dts8_out Actual results: ./KO_dts8_out ================================================================= ==11258==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffd106038f4 at pc 0x0000004007d8 bp 0x7ffd10603730 sp 0x7ffd10603720 READ of size 4 at 0x7ffd106038f4 thread T0 #0 0x4007d7 in main (/root/gcc_test/KO_dts8_out+0x4007d7) #1 0x7f09d0bb93d4 in __libc_start_main (/lib64/libc.so.6+0x223d4) #2 0x40087a (/root/gcc_test/KO_dts8_out+0x40087a) Additional info: and the expected behavior with devtoolset-6-gcc-6.3.1-3.1.el7.x86_64. attaching reproducer script for comparative analysis with devtoolset-6-gcc
Reproduced: # scl enable devtoolset-8 "gcc -g -O2 -flto -fsanitize=address s.c"; ./a.out ================================================================= ==19890==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffb52b6ce4 at pc 0x0000004007d8 bp 0x7fffb52b6b20 sp 0x7fffb52b6b10 READ of size 4 at 0x7fffb52b6ce4 thread T0 #0 0x4007d7 in main (/root/a.out+0x4007d7) # scl enable devtoolset-7 "gcc -g -O2 -flto -fsanitize=address s.c"; ./a.out ================================================================= ==19908==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffea3ba0624 at pc 0x0000004007d5 bp 0x7ffea3ba0460 sp 0x7ffea3ba0450 READ of size 4 at 0x7ffea3ba0624 thread T0 #0 0x4007d4 in main /root/s.c:4 I would suggest *not* using -flto when debugging. Moving to DTS 9; it doesn't seem to be fixed in GCC 8 upstream.
Trying again, this seems to be resolved in DTS 8.1 and in DTS 9.0: # scl enable devtoolset-8 "gcc -g -O2 -flto -fsanitize=address s.c"; ./a.out ================================================================= ==9398==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffce7409d34 at pc 0x0000004007d8 bp 0x7ffce7409b70 sp 0x7ffce7409b60 READ of size 4 at 0x7ffce7409d34 thread T0 #0 0x4007d7 in main /root/s.c:4 # scl enable devtoolset-9 "gcc -g -O2 -flto -fsanitize=address s.c"; ./a.out ================================================================= ==9416==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff5029e764 at pc 0x0000004011a6 bp 0x7fff5029e590 sp 0x7fff5029e580 READ of size 4 at 0x7fff5029e764 thread T0 #0 0x4011a5 in main /root/s.c:4 (Note the s.c:4). So I'm going to mark it as resolved.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHEA-2019:4134