This is an archive of the discontinued LLVM Phabricator instance.

sanitizer_common/symbolizer: fix crashes during exit
ClosedPublic

Authored by dvyukov on May 14 2021, 12:28 AM.

Details

Summary

Override __cxa_atexit and ignore callbacks.
This prevents crashes in a configuration when the symbolizer
is built into sanitizer runtime and consequently into the test process.
LLVM libraries have some global objects destroyed during exit,
so if the test process triggers any bugs after that, the symbolizer crashes.
An example stack trace of such crash:

For the standalone llvm-symbolizer this does not hurt,
we just don't destroy few global objects on exit.

Diff Detail

Event Timeline

dvyukov requested review of this revision.May 14 2021, 12:28 AM
dvyukov created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMay 14 2021, 12:28 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
dvyukov updated this revision to Diff 345360.May 14 2021, 12:30 AM

fix commit message to include stack

kda accepted this revision.May 14 2021, 10:34 AM

LGTM, but I don't know if I know enough to see something bad.

This revision is now accepted and ready to land.May 14 2021, 10:34 AM
This revision was landed with ongoing or failed builds.May 17 2021, 11:58 PM
This revision was automatically updated to reflect the committed changes.
vitalybuka added inline comments.Jun 10 2021, 11:42 PM
compiler-rt/test/tsan/atexit4.cpp
2

another solution is to build LLVM_ENABLE_THREADS=0
I assume this test triggers nothing in upstream, as upstream build is already with LLVM_ENABLE_THREADS=0?

vitalybuka added inline comments.Jun 10 2021, 11:45 PM
compiler-rt/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cpp
134

I think more appropriate place is sanitizer_wrappers.cpp as here we keep interface and there libc hacks

dvyukov added inline comments.Jun 11 2021, 12:01 AM
compiler-rt/test/tsan/atexit4.cpp
2

another solution is to build LLVM_ENABLE_THREADS=0

But won't globals still registered for destruction at exit?

I assume this test triggers nothing in upstream, as upstream build is already with LLVM_ENABLE_THREADS=0?

This is not triggered upstream, because upstream we don't compile symbolizer into sanitizers. Symbolizer as standalone process is not affected by the problem entirely.

vitalybuka added inline comments.Jun 11 2021, 12:33 AM
compiler-rt/test/tsan/atexit4.cpp
2

another solution is to build LLVM_ENABLE_THREADS=0

But won't globals still registered for destruction at exit?

Yes, they would, LLVM_ENABLE_THREADS will avoid recursive_mutex and this crash.
I like you solution, it's more future proof then just LLVM_ENABLE_THREADS.

I assume this test triggers nothing in upstream, as upstream build is already with LLVM_ENABLE_THREADS=0?

This is not triggered upstream, because upstream we don't compile symbolizer into sanitizers. Symbolizer as standalone process is not affected by the problem entirely.

We do https://lab.llvm.org/buildbot/#/builders/37/builds/4500 "with symbolizer" tests, but they are LLVM_ENABLE_THREADS=0