Bail second pass redirection after catch in thread abort on Unix (#72705)
authorJuan Hoyos <juan.hoyos@microsoft.com>
Tue, 26 Jul 2022 09:42:12 +0000 (02:42 -0700)
committerGitHub <noreply@github.com>
Tue, 26 Jul 2022 09:42:12 +0000 (02:42 -0700)
The redirection stub was never implemented, leading to crashes in scenarios like Debugger Function Evaluations. Instead of rethrowing the exception after the catch clause, this allows the ThreadAbortException to flow as any usual exception and hopefully surface through other points that call mechanisms like Thread::HandleThreadAbort. This is a behavior difference between Unix and non-Unix plaforms with some observable side effects, but Thread.Abort is not supported in core. Most commonly the debugger is the major scenario where ThreadAbort gets used, and this prevents the crash.

src/coreclr/vm/exceptionhandling.cpp

index 86b3afb..905ed56 100644 (file)
@@ -784,7 +784,11 @@ UINT_PTR ExceptionTracker::FinishSecondPass(
     {
         CopyOSContext(pThread->m_OSContext, pContextRecord);
         SetIP(pThread->m_OSContext, (PCODE)uResumePC);
+#ifdef TARGET_UNIX
+        uAbortAddr = NULL;
+#else
         uAbortAddr = (UINT_PTR)COMPlusCheckForAbort(uResumePC);
+#endif
     }
 
     if (uAbortAddr)