From 071688f28a62c541ab0e3e41fb90585ca687ca04 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Mon, 2 Aug 2021 18:00:26 +0200 Subject: [PATCH] Fix stack overflow handling issue in GC stress This change fixes a problem when in GC stress mode 3, GC started to run on the thread that hit stack overflow due to the GCX_PREEMP in DebuggerRCThread::DoFavor that is called from the EEPolicy::HandleFatalStackOverflow. It was causing failures in the CI. The issue is GC stress specific, the GCX_PREEMP would not start running GC on the current thread in regular cases. The fix is to inhibit GC stress in the HandleFatalStackOverflow. --- src/coreclr/vm/eepolicy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/coreclr/vm/eepolicy.cpp b/src/coreclr/vm/eepolicy.cpp index 1c250c7d40a09..9f1f9624941a5 100644 --- a/src/coreclr/vm/eepolicy.cpp +++ b/src/coreclr/vm/eepolicy.cpp @@ -616,6 +616,10 @@ void DECLSPEC_NORETURN EEPolicy::HandleFatalStackOverflow(EXCEPTION_POINTERS *pE WRAPPER_NO_CONTRACT; + // Disable GC stress triggering GC at this point, we don't want the GC to start running + // on this thread when we have only a very limited space left on the stack + GCStressPolicy::InhibitHolder iholder; + STRESS_LOG0(LF_EH, LL_INFO100, "In EEPolicy::HandleFatalStackOverflow\n"); FrameWithCookie fef;