This is an archive of the discontinued LLVM Phabricator instance.

[Windows] Use TerminateProcess to exit without running destructors
ClosedPublic

Authored by mstorsjo on May 21 2021, 1:54 PM.

Details

Summary

If exiting using _Exit or ExitProcess, DLLs are still unloaded
cleanly before exiting, running destructors and other cleanup in those
DLLs. When the caller expects to exit without cleanup, running
destructors in some loaded DLLs (which can be either libLLVM.dll or
e.g. libc++.dll) can cause deadlocks occasionally.

This is an alternative to D102684.

Diff Detail

Event Timeline

mstorsjo created this revision.May 21 2021, 1:54 PM
mstorsjo requested review of this revision.May 21 2021, 1:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 21 2021, 1:54 PM
rnk accepted this revision.May 21 2021, 2:34 PM

lgtm

Yep, this is more or less exactly what I had in mind. :)

This revision is now accepted and ready to land.May 21 2021, 2:34 PM

Let's hope this one puts the issue at rest, finally, then :-)

I'll push it tomorrow or so.

mati865 accepted this revision.May 21 2021, 4:25 PM

Feels like a heavy hammer to me but guess there is no better option.

Feels like a heavy hammer to me but guess there is no better option.

Well the whole early exit codepath in lld is a pretty special construct too, and I guess this is the closest match to the wanted behavior of ‘_Exit’ on windows...

This revision was landed with ongoing or failed builds.May 22 2021, 1:51 PM
This revision was automatically updated to reflect the committed changes.