From 61131ee5065d1b220612b47b4295fa1c349b356b Mon Sep 17 00:00:00 2001 From: David Mason Date: Tue, 16 Feb 2021 22:16:54 -0800 Subject: [PATCH] GCStress eventing fix --- src/vm/eventpipe.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/vm/eventpipe.cpp b/src/vm/eventpipe.cpp index 7eab2c82a95a..a84714b03751 100644 --- a/src/vm/eventpipe.cpp +++ b/src/vm/eventpipe.cpp @@ -699,11 +699,17 @@ bool EventPipe::WalkManagedStackForThread(Thread *pThread, StackContents &stackC stackContents.Reset(); + // Before we call into StackWalkFrames we need to mark GC_ON_TRANSITIONS as FALSE + // because under GCStress runs (GCStress=0x3), a GC will be triggered for every transition, + // which will cause the GC to try to walk the stack while we are in the middle of walking the stack. + bool gcOnTransitions = GC_ON_TRANSITIONS(FALSE); + StackWalkAction swaRet = pThread->StackWalkFrames( (PSTACKWALKFRAMESCALLBACK)&StackWalkCallback, &stackContents, ALLOW_ASYNC_STACK_WALK | FUNCTIONSONLY | HANDLESKIPPEDFRAMES | ALLOW_INVALID_OBJECTS); + GC_ON_TRANSITIONS(gcOnTransitions); return ((swaRet == SWA_DONE) || (swaRet == SWA_CONTINUE)); }