AddressSanitizer with LTO does not show file name and line number in backtrace
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc-8 (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Using ASan/UBSan with LTO leads to printing of only hex offsets in the stacktraces. The issue seems to be fixed in gcc-9 on Eoan, but it doesnt work with bionic gcc-8.
There is a GCC bug for this, which was fixed an year ago, but it is not there in bionic gcc-8.
https:/
I have attached a simple test program to demonstrate the problem, which is compiled with following options:
$ gcc -flto -g -fsanitize=address -o leak leak.c
With bionic, gcc-8 gives:
Direct leak of 4 byte(s) in 1 object(s) allocated from:
#0 0x7f35f6106f00 in __interceptor_
#1 0x56193a9fb7f6 in leak (/home/
#2 0x56193a9fb812 in main (/home/
#3 0x7f35f5c49b96 in __libc_start_main (/lib/x86_
With Eoan, gcc-9 gives:
Direct leak of 4 byte(s) in 1 object(s) allocated from:
#0 0x7fb3baa7eae8 in malloc (/lib/x86_
#1 0x55c775c2e16a in leak /home/asachan/
#2 0x55c775c2e186 in main /home/asachan/
#3 0x7fb3ba7a71e2 in __libc_start_main (/lib/x86_
The fix seems to be in libbacktrace, which gets picked up in libsanitizer as well:
https:/
In case you are trying to reproduce this issue in Eoan with gcc-8, it wont be visible because libasan is same for gcc-8 and gcc-9, and libasan
for gcc-9 has the fix which works for gcc-8 as well.
Eoan gcc-v output:
gcc -v LTO_WRAPPER= /usr/lib/ gcc/x86_ 64-linux- gnu/9/lto- wrapper TARGET_ NAMES=nvptx- none:hsa TARGET_ DEFAULT= 1 pkgversion= 'Ubuntu 9.2.1-9ubuntu2' --with- bugurl= file:// /usr/share/ doc/gcc- 9/README. Bugs --enable- languages= c,ada,c+ +,go,brig, d,fortran, objc,obj- c++,gm2 --prefix=/usr --with- gcc-major- version- only --program-suffix=-9 --program- prefix= x86_64- linux-gnu- --enable-shared --enable- linker- build-id --libexecdir= /usr/lib --without- included- gettext --enable- threads= posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable- clocale= gnu --enable- libstdcxx- debug --enable- libstdcxx- time=yes --with- default- libstdcxx- abi=new --enable- gnu-unique- object --disable- vtable- verify --enable-plugin --enable- default- pie --with-system-zlib --with- target- system- zlib=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with- multilib- list=m32, m64,mx32 --enable-multilib --with-tune=generic --enable- offload- targets= nvptx-none, hsa --without- cuda-driver --enable- checking= release --build= x86_64- linux-gnu --host= x86_64- linux-gnu --target= x86_64- linux-gnu
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_
OFFLOAD_
OFFLOAD_
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-
Thread model: posix
gcc version 9.2.1 20191008 (Ubuntu 9.2.1-9ubuntu2)
Bionic, gcc -v output: LTO_WRAPPER= /usr/lib/ gcc/x86_ 64-linux- gnu/8/lto- wrapper TARGET_ NAMES=nvptx- none TARGET_ DEFAULT= 1 pkgversion= 'Ubuntu 8.3.0-6ubuntu1~ 18.04.1' --with- bugurl= file:// /usr/share/ doc/gcc- 8/README. Bugs --enable- languages= c,ada,c+ +,go,brig, d,fortran, objc,obj- c++ --prefix=/usr --with- gcc-major- version- only --program-suffix=-8 --program- prefix= x86_64- linux-gnu- --enable-shared --enable- linker- build-id --libexecdir= /usr/lib --without- included- gettext --enable- threads= posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable- clocale= gnu --enable- libstdcxx- debug --enable- libstdcxx- time=yes --with- default- libstdcxx- abi=new --enable- gnu-unique- object --disable- vtable- verify --enable-libmpx --enable-plugin --enable- default- pie --with-system-zlib --with- target- system- zlib --enable- objc-gc= auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with- multilib- list=m32, m64,mx32 --enable-multilib --with-tune=generic --enable- offload- targets= nvptx-none --without- cuda-driver --enable- checking= release --build= x86_64- linux-gnu --host= x86_64- linux-gnu --target= x86_64- linux-gnu 18.04.1)
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_
OFFLOAD_
OFFLOAD_
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-
Thread model: posix
gcc version 8.3.0 (Ubuntu 8.3.0-6ubuntu1~