[libunwind] [SEH] Don't interact with foreign exceptions
authorMartin Storsjö <martin@martin.st>
Wed, 27 Nov 2019 13:55:53 +0000 (15:55 +0200)
committerMartin Storsjö <martin@martin.st>
Mon, 12 Oct 2020 20:28:22 +0000 (23:28 +0300)
commitfc5e68fab965bdc8fdf6db9ae2603f9dd02dec5b
tree563bca7adb585dfdc8a504fc0ae2dde8f24f99eb
parent8b6cd15242673c04618fb0aafc07d5de9e0bbe1e
[libunwind] [SEH] Don't interact with foreign exceptions

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.

Differential Revision: https://reviews.llvm.org/D89231
libunwind/src/Unwind-seh.cpp