Bug 1653814 - symbolized stack traces no longer available when -flto and -fsanitize are used
Summary: symbolized stack traces no longer available when -flto and -fsanitize are used
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Developer Toolset
Classification: Red Hat
Component: gcc
Version: DTS 8.0 RHEL 7
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: alpha
: 8.1
Assignee: Marek Polacek
QA Contact: Alexandra Petlanová Hájková
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-11-27 16:53 UTC by Piyush Bhoot
Modified: 2023-03-24 14:23 UTC (History)
8 users (show)

Fixed In Version: devtoolset-9-gcc-9.1.1-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-12-10 07:49:25 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
reproducer (339 bytes, text/plain)
2018-11-27 16:53 UTC, Piyush Bhoot
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2019:4134 0 None None None 2019-12-10 07:49:45 UTC

Description Piyush Bhoot 2018-11-27 16:53:22 UTC
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

Comment 2 Marek Polacek 2018-12-03 21:10:53 UTC
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.

Comment 4 Marek Polacek 2019-07-11 19:52:36 UTC
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.

Comment 9 errata-xmlrpc 2019-12-10 07:49:25 UTC
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


Note You need to log in before you can comment on or make changes to this bug.