[ASAN] fix startup crash in dlsym for long paths since glibc 2.27
authorPeter Wu <peter@lekensteyn.nl>
Thu, 14 Jun 2018 10:42:54 +0000 (10:42 +0000)
committerPeter Wu <peter@lekensteyn.nl>
Thu, 14 Jun 2018 10:42:54 +0000 (10:42 +0000)
commit1bbab1e558523e8a3acce350250fc85819a7ebf3
tree78afb297c470e7bc68f2b7da1d76d2ecd1173fe8
parent2e6384038cd89ad844deaa2e3e1854c8573ce262
[ASAN] fix startup crash in dlsym for long paths since glibc 2.27

Summary:
Error messages for dlsym used to be stored on the stack, but since
commit 2449ae7b ("ld.so: Introduce struct dl_exception") in glibc 2.27
these are now stored on the heap (and thus use the dlsym alloc pool).

Messages look like "undefined symbol: __isoc99_printf\0/path/to/a.out".
With many missing library functions and long object paths, the pool is
quickly exhausted. Implement a simple mechanism to return freed memory
to the pool (clear it in case it is used for calloc).

Fixes https://github.com/google/sanitizers/issues/957

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D47995

llvm-svn: 334703
compiler-rt/lib/asan/asan_malloc_linux.cc
compiler-rt/test/asan/TestCases/long-object-path.cc [new file with mode: 0644]