From de13dbf8554e6cbd97f000eb0d0b909184150a24 Mon Sep 17 00:00:00 2001 From: Sung Yoon Whang Date: Fri, 20 Sep 2019 14:37:45 -0700 Subject: [PATCH] Mark GC_TRANSITION(FALSE) for EventPipe stack sampling (dotnet/coreclr#26776) * Mark GC_TRANSITION for collecting stacks * Add some comments Commit migrated from https://github.com/dotnet/coreclr/commit/d8b7989d76cf239586abbc5c604af245e2b2fc1f --- src/coreclr/src/vm/eventpipe.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/coreclr/src/vm/eventpipe.cpp b/src/coreclr/src/vm/eventpipe.cpp index 16d2db5..53fec78 100644 --- a/src/coreclr/src/vm/eventpipe.cpp +++ b/src/coreclr/src/vm/eventpipe.cpp @@ -716,11 +716,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)); } -- 2.7.4