This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Fix a crash when demangling Swift symbols, take 2
ClosedPublic

Authored by kubamracek on May 6 2016, 5:25 AM.

Details

Summary

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.

Diff Detail

Event Timeline

kubamracek updated this revision to Diff 56405.May 6 2016, 5:25 AM
kubamracek retitled this revision from to [sanitizer] Fix a crash when demangling Swift symbols, take 2.
kubamracek updated this object.
kubamracek added a project: Restricted Project.
kubamracek added subscribers: llvm-commits, dcoughlin.
aizatsky accepted this revision.May 10 2016, 11:33 AM
aizatsky edited edge metadata.
This revision is now accepted and ready to land.May 10 2016, 11:33 AM
This revision was automatically updated to reflect the committed changes.