This is an archive of the discontinued LLVM Phabricator instance.

Fix race condition in order-of-destruction between SectionMemoryManager and its MemoryMapper
ClosedPublic

Authored by sgraenitz on Jul 3 2023, 6:01 AM.

Details

Summary

SectionMemoryManager's default memory mapper used to be a global static
object. If the SectionMemoryManager itself is a global static
object, it might be destroyed after its memory mapper and thus couldn't
use it from the destructor.

The Kaleidoscope tutorial reproduced this situation with MSVC for a long time.
Since 47f5c54f997a59bb2c65 it's trigger with GCC as well. The solution from
this patch was proposed in the existing review https://reviews.llvm.org/D107087
before, but it didn't move forward.

Diff Detail

Event Timeline

sgraenitz created this revision.Jul 3 2023, 6:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 3 2023, 6:01 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
sgraenitz requested review of this revision.Jul 3 2023, 6:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 3 2023, 6:01 AM
sgraenitz edited the summary of this revision. (Show Details)Jul 3 2023, 6:05 AM
nikic accepted this revision.Jul 4 2023, 7:58 AM

LGTM. I confirmed that this does fix the GCC issue.

This revision is now accepted and ready to land.Jul 4 2023, 7:58 AM