[PATCH] D20015: [sanitizer] Fix a crash when demangling Swift symbols, take 2

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Fri May 6 05:25:25 PDT 2016


kubabrecka created this revision.
kubabrecka added reviewers: dvyukov, zaks.anna, glider, kcc, samsonov, aizatsky.
kubabrecka added subscribers: llvm-commits, dcoughlin.
kubabrecka added a project: Sanitizers.
Herald added a subscriber: kubabrecka.

Original patch at http://reviews.llvm.org/D19974 caused failures in MSan.

> 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.

http://reviews.llvm.org/D20015

Files:
  lib/asan/asan_rtl.cc
  lib/sanitizer_common/sanitizer_symbolizer.h
  lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
  lib/sanitizer_common/sanitizer_symbolizer_win.cc
  lib/tsan/rtl/tsan_rtl.cc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20015.56405.patch
Type: text/x-patch
Size: 4142 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160506/e7955ff2/attachment.bin>


More information about the llvm-commits mailing list