[compiler-rt] r269291 - [sanitizer] Fix a crash when demangling Swift symbols, take 2

H.J. Lu via llvm-commits llvm-commits at lists.llvm.org
Sun May 15 09:10:38 PDT 2016


On Thu, May 12, 2016 at 6:11 AM, Kuba Brecka via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: kuba.brecka
> Date: Thu May 12 08:11:03 2016
> New Revision: 269291
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269291&view=rev
> Log:
> [sanitizer] Fix a crash when demangling Swift symbols, take 2
>
> To invoke the Swift demangler, we use dlsym to locate swift_demangle. However, dlsym malloc's storage and stores it in thread-local storage. Since allocations from the symbolizer are done with the system allocator (at least in TSan, interceptors are skipped when inside the symbolizer), we will crash when we try to deallocate later using the sanitizer allocator again.
>
> To fix this, let's just not call dlsym from the demangler, and call it during initialization. The dlsym function calls malloc, so it needs to be only used after our allocator is initialized. Adding a Symbolizer::LateInitialize call that is only invoked after all other initializations.
>
> Differential Revision: http://reviews.llvm.org/D20015
>
>
> Modified:
>     compiler-rt/trunk/lib/asan/asan_rtl.cc
>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h
>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_win.cc
>     compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
>

This caused:

https://llvm.org/bugs/show_bug.cgi?id=27745

-- 
H.J.


More information about the llvm-commits mailing list