<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - LLD doesn't link sanitizer runtimes in C++ link correctly"
href="https://llvm.org/bugs/show_bug.cgi?id=31939">31939</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>LLD doesn't link sanitizer runtimes in C++ link correctly
</td>
</tr>
<tr>
<th>Product</th>
<td>lld
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>ELF
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>chandlerc@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Here are steps to reproduce:
% cat test.cpp
#include <malloc.h>
int main() {
free(malloc(42));
}
% ~/bin/clang++ -fsanitize=address -fuse-ld=lld -o test test.cpp -v
clang version 5.0.0 (trunk 292694) (llvm/trunk 292757)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/chandlerc/bin
Selected GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
"/home/chandlerc/installs/llvm-2017-01-22/bin/clang-5.0" -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
test.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-fuse-init-array -target-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb
-resource-dir /home/chandlerc/installs/llvm-2017-01-22/bin/../lib64/clang/5.0.0
-internal-isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3
-internal-isystem
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/x86_64-pc-linux-gnu
-internal-isystem
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/backward
-internal-isystem /usr/local/include -internal-isystem
/home/chandlerc/installs/llvm-2017-01-22/bin/../lib64/clang/5.0.0/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdeprecated-macro -fdebug-compilation-dir /home/chandlerc/src/llvm.git/build
-ferror-limit 19 -fmessage-length 283 -fsanitize=address
-fsanitize-blacklist=/home/chandlerc/installs/llvm-2017-01-22/bin/../lib64/clang/5.0.0/asan_blacklist.txt
-fno-assume-sane-operator-new -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -o /tmp/test-dc73b2.o -x c++
test.cpp
clang -cc1 version 5.0.0 based upon LLVM 5.0.0svn default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/x86_64-pc-linux-gnu
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/backward
/home/chandlerc/installs/llvm-2017-01-22/bin/../lib64/clang/5.0.0/include
/usr/include
End of search list.
"/home/chandlerc/bin/ld.lld" --eh-frame-hdr -m elf_x86_64 -dynamic-linker
/lib64/ld-linux-x86-64.so.2 -o test
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../lib64/crt1.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../lib64/crti.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../lib64
-L/home/chandlerc/installs/llvm-2017-01-22/bin/../lib64 -L/lib/../lib64
-L/usr/lib/../lib64
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../x86_64-pc-linux-gnu/lib
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../.. -L/lib -L/usr/lib
-whole-archive
/home/chandlerc/installs/llvm-2017-01-22/bin/../lib64/clang/5.0.0/lib/linux/libclang_rt.asan-x86_64.a
-no-whole-archive
--dynamic-list=/home/chandlerc/installs/llvm-2017-01-22/bin/../lib64/clang/5.0.0/lib/linux/libclang_rt.asan-x86_64.a.syms
-whole-archive
/home/chandlerc/installs/llvm-2017-01-22/bin/../lib64/clang/5.0.0/lib/linux/libclang_rt.asan_cxx-x86_64.a
-no-whole-archive
--dynamic-list=/home/chandlerc/installs/llvm-2017-01-22/bin/../lib64/clang/5.0.0/lib/linux/libclang_rt.asan_cxx-x86_64.a.syms
/tmp/test-dc73b2.o -lstdc++ -lm --no-as-needed -lpthread -lrt -lm -ldl -lgcc_s
-lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtend.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../lib64/crtn.o
% nm test | grep malloc
000000000051f5e8 b _ZN14__interception11real_mallocE
0000000000521648 b _ZN14__interception17real_malloc_statsE
0000000000521618 b _ZN14__interception23real_malloc_usable_sizeE
000000000022d660 t
_ZN6__asan11asan_mallocEmPN11__sanitizer18BufferedStackTraceE
000000000022d8c0 t _ZN6__asan23asan_malloc_usable_sizeEPKvmm
00000000005228e0 b _ZN6__asanL19malloc_context_sizeE
0000000000522d90 b _ZN6__asanL19max_malloced_memoryE
0000000000238670 t __asan_stack_malloc_0
0000000000238990 t __asan_stack_malloc_1
000000000023abf0 t __asan_stack_malloc_10
0000000000238ce0 t __asan_stack_malloc_2
0000000000239070 t __asan_stack_malloc_3
0000000000239450 t __asan_stack_malloc_4
00000000002398e0 t __asan_stack_malloc_5
0000000000239e90 t __asan_stack_malloc_6
000000000023a210 t __asan_stack_malloc_7
000000000023a560 t __asan_stack_malloc_8
000000000023a8b0 t __asan_stack_malloc_9
00000000002d5450 t __interceptor_malloc
00000000002d6400 t __interceptor_malloc_stats
00000000002d5f00 t __interceptor_malloc_usable_size
00000000002e3940 t __sanitizer_install_malloc_and_free_hooks
w __sanitizer_malloc_hook
00000000002d5450 t malloc
00000000002d6400 t malloc_stats
00000000002d5f00 t malloc_usable_size
These 't' symbols should be 'T'. This is the output from using binutils ld:
% clang++ -fsanitize=address -o test test.cpp -v
clang version 5.0.0 (trunk 292694) (llvm/trunk 292757)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/chandlerc/bin
Selected GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
"/home/chandlerc/installs/llvm-2017-01-22/bin/clang-5.0" -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
test.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-fuse-init-array -target-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb
-resource-dir /home/chandlerc/installs/llvm-2017-01-22/bin/../lib64/clang/5.0.0
-internal-isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3
-internal-isystem
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/x86_64-pc-linux-gnu
-internal-isystem
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/backward
-internal-isystem /usr/local/include -internal-isystem
/home/chandlerc/installs/llvm-2017-01-22/bin/../lib64/clang/5.0.0/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdeprecated-macro -fdebug-compilation-dir /home/chandlerc/src/llvm.git/build
-ferror-limit 19 -fmessage-length 283 -fsanitize=address
-fsanitize-blacklist=/home/chandlerc/installs/llvm-2017-01-22/bin/../lib64/clang/5.0.0/asan_blacklist.txt
-fno-assume-sane-operator-new -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -o /tmp/test-7eda00.o -x c++
test.cpp
clang -cc1 version 5.0.0 based upon LLVM 5.0.0svn default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/x86_64-pc-linux-gnu
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/backward
/home/chandlerc/installs/llvm-2017-01-22/bin/../lib64/clang/5.0.0/include
/usr/include
End of search list.
"/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../x86_64-pc-linux-gnu/bin/ld"
--eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o
test /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../lib64/crt1.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../lib64/crti.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../lib64
-L/home/chandlerc/installs/llvm-2017-01-22/bin/../lib64 -L/lib/../lib64
-L/usr/lib/../lib64
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../x86_64-pc-linux-gnu/lib
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../.. -L/lib -L/usr/lib
-whole-archive
/home/chandlerc/installs/llvm-2017-01-22/bin/../lib64/clang/5.0.0/lib/linux/libclang_rt.asan-x86_64.a
-no-whole-archive
--dynamic-list=/home/chandlerc/installs/llvm-2017-01-22/bin/../lib64/clang/5.0.0/lib/linux/libclang_rt.asan-x86_64.a.syms
-whole-archive
/home/chandlerc/installs/llvm-2017-01-22/bin/../lib64/clang/5.0.0/lib/linux/libclang_rt.asan_cxx-x86_64.a
-no-whole-archive
--dynamic-list=/home/chandlerc/installs/llvm-2017-01-22/bin/../lib64/clang/5.0.0/lib/linux/libclang_rt.asan_cxx-x86_64.a.syms
/tmp/test-7eda00.o -lstdc++ -lm --no-as-needed -lpthread -lrt -lm -ldl -lgcc_s
-lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtend.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../lib64/crtn.o
% nm test | grep malloc
00000000007372e8 b _ZN14__interception11real_mallocE
0000000000739348 b _ZN14__interception17real_malloc_statsE
0000000000739318 b _ZN14__interception23real_malloc_usable_sizeE
000000000041ac10 t
_ZN6__asan11asan_mallocEmPN11__sanitizer18BufferedStackTraceE
000000000041ae70 t _ZN6__asan23asan_malloc_usable_sizeEPKvmm
000000000073a5e0 b _ZN6__asanL19malloc_context_sizeE
000000000073aa90 b _ZN6__asanL19max_malloced_memoryE
0000000000425c10 T __asan_stack_malloc_0
0000000000425f30 T __asan_stack_malloc_1
0000000000428190 T __asan_stack_malloc_10
0000000000426280 T __asan_stack_malloc_2
0000000000426610 T __asan_stack_malloc_3
00000000004269f0 T __asan_stack_malloc_4
0000000000426e80 T __asan_stack_malloc_5
0000000000427430 T __asan_stack_malloc_6
00000000004277b0 T __asan_stack_malloc_7
0000000000427b00 T __asan_stack_malloc_8
0000000000427e50 T __asan_stack_malloc_9
00000000004c29f0 T __interceptor_malloc
00000000004c39a0 T __interceptor_malloc_stats
00000000004c34a0 T __interceptor_malloc_usable_size
00000000004d0ed0 T __sanitizer_install_malloc_and_free_hooks
w __sanitizer_malloc_hook
00000000004c29f0 W malloc
00000000004c39a0 W malloc_stats
00000000004c34a0 W malloc_usable_size
Huge thanks to Peter and Vitaly who helped me track this down, and Richard to
convinced me that my script could work to debug it. The only way I noticed this
is that the mismatched interceptors make llvm-symbolizer crash in a weird way,
and that was not as easy place to start debugging from.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>