Skip to content

Commit

Permalink
Fix stack overflow reporting from native code (dotnet#56774)
Browse files Browse the repository at this point in the history
* Fix stack overflow reporting from native code

When stack overflow happens in native code, the stack walker is unable
to walk the stack and we end up reporting no call stack at all.

This change fixes it by first unwinding the exception context to the first
managed frame and then letting the stack walker to walk the frames.

* Revert behavior for the Windows x86 case
  • Loading branch information
janvorli committed Aug 4, 2021
1 parent 571b4b4 commit 7d76a64
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/coreclr/vm/eepolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,13 @@ void DECLSPEC_NORETURN EEPolicy::HandleFatalStackOverflow(EXCEPTION_POINTERS *pE
if (pExceptionInfo && pExceptionInfo->ContextRecord)
{
GCX_COOP();
#if defined(TARGET_X86) && defined(TARGET_WINDOWS)
// For Windows x86, we don't have a reliable method to unwind to the first managed call frame,
// so we handle at least the cases when the stack overflow happens in JIT helpers
AdjustContextForJITHelpers(pExceptionInfo->ExceptionRecord, pExceptionInfo->ContextRecord);
#else
Thread::VirtualUnwindToFirstManagedCallFrame(pExceptionInfo->ContextRecord);
#endif
fef.InitAndLink(pExceptionInfo->ContextRecord);
}

Expand Down

0 comments on commit 7d76a64

Please sign in to comment.