Bug#876973: clang-4.0: -fsanitize=address + -lc = segmentation fault
Jakub Wilk
jwilk at jwilk.net
Wed Sep 27 08:51:44 UTC 2017
Package: clang-4.0
Version: 1:4.0.1-3
When you build a program with AddressSanitizer and link it explicitly
with libc, the program segfaults immediately:
$ cat hello.c
#include <stdio.h>
int main(int argc, char **argv)
{
printf("Hello world!\n");
return 0;
}
$ clang-4.0 -fsanitize=address hello.c -o hello -lc
$ ./hello
Segmentation fault
Backtrace:
#0 0xf7fe4f5a in elf_machine_rel (skip_ifunc=<optimized out>, reloc_addr_arg=0x81a5530, version=<optimized out>, sym=0x804b97c, reloc=0x805d28c, map=0xf7ffd920) at ../sysdeps/i386/dl-machine.h:316
#1 elf_dynamic_do_Rel (skip_ifunc=<optimized out>, lazy=<optimized out>, nrelative=<optimized out>, relsize=<optimized out>, reladdr=<optimized out>, map=<optimized out>) at do-rel.h:137
#2 _dl_relocate_object (scope=<optimized out>, reloc_mode=<optimized out>, consider_profiling=<optimized out>) at dl-reloc.c:259
#3 0xf7fdcb2f in dl_main (phdr=<optimized out>, phnum=<optimized out>, user_entry=<optimized out>, auxv=<optimized out>) at rtld.c:2204
#4 0xf7fefe8b in _dl_sysdep_start (start_argptr=0xffffd780, dl_main=0xf7fdabe0 <dl_main>) at ../elf/dl-sysdep.c:249
#5 0xf7fda792 in _dl_start_final (arg=0xffffd780) at rtld.c:414
#6 _dl_start (arg=<optimized out>) at rtld.c:520
#7 0xf7fd9a27 in _start () from /lib/ld-linux.so.2
NB, this works with GCC:
$ gcc-7 -fsanitize=address hello.c -o hello -lc
$ ./hello
Hello world!
-- System Information:
Architecture: i386
Versions of packages clang-4.0 depends on:
ii libc6 2.24-17
ii libclang1-4.0 1:4.0.1-3
ii libgcc1 1:7.2.0-7
ii libjsoncpp1 1.7.4-3
ii libllvm4.0 1:4.0.1-3
ii libstdc++6 7.2.0-7
ii libstdc++-7-dev 7.2.0-7
ii libgcc-7-dev 7.2.0-7
ii libobjc-7-dev 7.2.0-7
ii libclang-common-4.0-dev 1:4.0.1-3
ii libc6-dev 2.24-17
ii binutils 2.29.1-3
Versions of packages clang-4.0 recommends:
ii llvm-4.0-dev 1:4.0.1-3
ii python 2.7.14-1
--
Jakub Wilk
More information about the Pkg-llvm-team
mailing list