This is an archive of the discontinued LLVM Phabricator instance.

Control lifetime of SectionMemoryManager's DefaultMMapper
AcceptedPublic

Authored by karies on Mar 2 2021, 9:55 AM.

Details

Reviewers
lhames
Summary

As the DefaultMMapper object is a namespace-level variable, its destruction happens unsynchronized with uses. ~SectionMemoryManager() needs MMapper which might have been destructed before the call to ~SectionMemoryManager() in cases where ~SectionMemoryManager() is triggered by some other static destruction.

To sort this out, make the DefaultMMapper object function-local. That way its construction happens before the first use (which might be static initialization), and its destruction is sequenced after that use's static destruction. This allows the use of the default SectionMemoryManager by objects with static storage duration.

Diff Detail

Event Timeline

karies created this revision.Mar 2 2021, 9:55 AM
karies requested review of this revision.Mar 2 2021, 9:55 AM
lhames accepted this revision.Mar 2 2021, 2:09 PM

LGTM.

This revision is now accepted and ready to land.Mar 2 2021, 2:09 PM