Skip to content

Commit 82b67ac

Browse files
committed
Make longjmp over managed frames work
The new exception handling has broken hosting Lua on Windows when a Lua code throws an exception that ends up crossing managed frames. Lua uses longjmp for its exception handling mechanism and the new exception handling reported the longjmp as an unhandled `SEHException`. This change makes the new EH ignore the `STATUS_LONGJUMP` exception when it passes through managed frames, so it can reach the target location. It is a best effort fix though, as finallys in the skipped frames won't be called. Close dotnet#111242
1 parent 289aa17 commit 82b67ac

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/coreclr/vm/exceptionhandling.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,13 @@ ProcessCLRExceptionNew(IN PEXCEPTION_RECORD pExceptionRecord,
932932

933933
Thread* pThread = GetThread();
934934

935+
if (pExceptionRecord->ExceptionCode == STATUS_LONGJUMP)
936+
{
937+
// This is an exception used to unwind during longjmp function. We just let it pass through managed
938+
// frames without any interaction.
939+
return ExceptionContinueSearch;
940+
}
941+
935942
if (pThread->HasThreadStateNC(Thread::TSNC_ProcessedUnhandledException))
936943
{
937944
if ((pExceptionRecord->ExceptionFlags & EXCEPTION_UNWINDING))

0 commit comments

Comments
 (0)