Search code examples
address-sanitizer

AddressSanitizer: SEGV in _dl_get_tls_static_info


I'm trying to get ASAN working with one program, but anything I did led to ASAN:DEADLYSIGNAL, so I tried to narrow it down and instrument a small test program with only a few compiler options, just to see if it will work at all:

$ cat > test.c <<EOF
int main(void) { return 0; }
EOF

Here's the command line:

$ gcc -g -O0 -fno-omit-frame-pointer -fsanitize=address test.c && ./a.out
ASAN:DEADLYSIGNAL
=================================================================
==5711==ERROR: AddressSanitizer: SEGV on unknown address 0xb7f11e70 (pc 0xb7f11e84 bp 0xb7ab6320 sp 0xbf92368c T16777215)
==5711==The signal is caused by a WRITE memory access.
    #0 0xb7f11e83 in _dl_get_tls_static_info (/lib/ld-linux.so.2+0x11e83)
    #1 0xb7a24ff9  (/usr/lib/i386-linux-gnu/libasan.so.4+0x101ff9)
    #2 0xb7a10f15  (/usr/lib/i386-linux-gnu/libasan.so.4+0xedf15)
    #3 0xb7f0f91a  (/lib/ld-linux.so.2+0xf91a)
    #4 0xb7f00cb9  (/lib/ld-linux.so.2+0xcb9)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/lib/ld-linux.so.2+0x11e83) in _dl_get_tls_static_info
==5711==ABORTING

(The same error I got for the "real" program.)

With -static-libasan the stack trace is just a bit more descriptive:

$ gcc -g -O0 -fno-omit-frame-pointer -fsanitize=address -static-libasan test.c && ./a.out
ASAN:DEADLYSIGNAL
=================================================================
==5719==ERROR: AddressSanitizer: SEGV on unknown address 0xb7fc6e70 (pc 0xb7fc6e84 bp 0x005f91a0 sp 0xbfe77c2c T16777215)
==5719==The signal is caused by a WRITE memory access.
    #0 0xb7fc6e83 in _dl_get_tls_static_info (/lib/ld-linux.so.2+0x11e83)
    #1 0x560a49 in __sanitizer::InitTlsSize() (/home/gkirilov/test/a.out+0xe9a49)
    #2 0x552e05 in __asan::AsanInitInternal() (/home/gkirilov/test/a.out+0xdbe05)
    #3 0xb7fc491a  (/lib/ld-linux.so.2+0xf91a)
    #4 0xb7fb5cb9  (/lib/ld-linux.so.2+0xcb9)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/lib/ld-linux.so.2+0x11e83) in _dl_get_tls_static_info
==5719==ABORTING

Here are some details about the system:

$ uname -a
Linux drinkpad 4.14.0-3-686-pae #1 SMP Debian 4.14.17-1 (2018-02-14) i686 GNU/Linux

$ gcc --version
gcc (Debian 7.3.0-11) 7.3.0

$ /lib/i386-linux-gnu/libc-2.27.so
Compiled by GNU CC version 7.3.0.
libc ABIs: UNIQUE IFUNC

I also tried clang-6 and gcc-8 (which brings ASAN v5 with it), again, with static and shared libasan, and I got the same messages.

Is my platform not supported? But then, I installed all tools from the official Debian repositories.

The home page of ASAN says that it has only been tested on 64-bit Ubuntu, but I think it is outdated, as the table just above it lists both Linux x86 and x86_64.

Am I doing anything wrong or is my platform not supported?


Solution

  • You are facing a known Asan bug (here's Glibc thread and GCC bug). TLDR is that it fails on Glibc 2.25+ because Glibc changed some internal interfaces that Asan relied upon. Sadly this bug hasn't got enough attention yet.