Skip to content

Commit bca7bfa

Browse files
authored
Fix thread abort issue with funceval (#118354)
There is a problem with threadabort in funceval in case there is no managed frame on the stack between the abortion point and the `FuncEvalFrame`. That can happen e.g. when invoking a static method via funceval for a type with static constructor that was not invoked yet and takes a long time to complete. The problem is caused by the fact that when EH is called to propagate the ThreadAbortException, it starts at the first managed frame and so it skips the try/catch in the funceval native code. This change fixes it by using `RaiseTheExceptionInternalOnly` to raise the `ThreadAbortException` in the `Thread::HandleThreadAbort`. The `Thread::HandleThreadAbort` is always called by native code that has a native catch or (on Windows) ends up calling the `ProcessCLRException`. I have originally made the change to call the `DispatchManagedException` from the `Thread::HandleThreadAbort`, but this issue shows it is problematic. I have verified that the repro provided by @eterekhin in the issue report no longer causes the process to crash with failfast, but reports the funceval as timed out as expected. Close #118015
1 parent a44f532 commit bca7bfa

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

src/coreclr/vm/threadsuspend.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2303,11 +2303,7 @@ void Thread::HandleThreadAbort ()
23032303
exceptObj = CLRException::GetThrowableFromException(&eeExcept);
23042304
}
23052305

2306-
#ifdef FEATURE_EH_FUNCLETS
2307-
DispatchManagedException(exceptObj);
2308-
#else // FEATURE_EH_FUNCLETS
23092306
RaiseTheExceptionInternalOnly(exceptObj, FALSE);
2310-
#endif // FEATURE_EH_FUNCLETS
23112307
}
23122308

23132309
::SetLastError(lastError);

0 commit comments

Comments
 (0)