This is an archive of the discontinued LLVM Phabricator instance.

[libunwind] [SEH] Don't interact with foreign exceptions
ClosedPublic

Authored by mstorsjo on Oct 12 2020, 4:16 AM.

Details

Summary

This unfortunately means that we don't execute C++ destructors when unwinding past such frames for a different SEH unwind purpose (e.g. as part of setjmp/longjmp), but that case isn't handled properly at the moment (the original unwind intent is lost and we end up with an unhandled exception). This patch makes sure the foreign unwind terminates as intended.

After executing a handler, _Unwind_Resume doesn't have access to the target frame parameter of the original foreign unwind. We also currently blindly set ExceptionCode to STATUS_GCC_THROW - we could set that correctly by storing the original code in _GCC_specific_handler, but we don't have access to the original target frame value.

This also matches what libgcc's SEH unwinding code does in this case.

Diff Detail

Event Timeline

mstorsjo created this revision.Oct 12 2020, 4:16 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 12 2020, 4:16 AM
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald Transcript
mstorsjo requested review of this revision.Oct 12 2020, 4:16 AM
compnerd accepted this revision.Oct 12 2020, 8:31 AM

Personally, I think that switch is nicer for the ExceptionCode check, but thats not your doing nor a real concern.

This revision is now accepted and ready to land.Oct 12 2020, 8:31 AM
rnk accepted this revision.Oct 12 2020, 11:44 AM

lgtm, I agree this is the right behavior.

This revision was automatically updated to reflect the committed changes.