From: Jan Vorlicek Date: Wed, 4 Aug 2021 20:00:04 +0000 (+0200) Subject: Fix stack overflow reporting from native code (#56774) X-Git-Tag: accepted/tizen/unified/20220110.054933~651 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7d76a64bd922ca34dc17224001d7e505c914ba6c;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Fix stack overflow reporting from native code (#56774) * 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 --- diff --git a/src/coreclr/vm/eepolicy.cpp b/src/coreclr/vm/eepolicy.cpp index 9f1f962..b908456 100644 --- a/src/coreclr/vm/eepolicy.cpp +++ b/src/coreclr/vm/eepolicy.cpp @@ -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); }