Skip to content

Commit e98d71d

Browse files
author
John Salem
authored
Correctly Save GC Mode on Suspension on Windows for SampleProfiler (#59974)
1 parent bcfa532 commit e98d71d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/coreclr/vm/threadsuspend.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3331,11 +3331,16 @@ void ThreadSuspend::SuspendRuntime(ThreadSuspend::SUSPEND_REASON reason)
33313331
STRESS_LOG3(LF_SYNC, LL_INFO10000, " Inspecting thread 0x%x ID 0x%x coop mode = %d\n",
33323332
thread, thread->GetThreadId(), thread->m_fPreemptiveGCDisabled.LoadWithoutBarrier());
33333333

3334+
33343335
// ::FlushProcessWriteBuffers above guarantees that the state that we see here
33353336
// is after the trap flag is visible to the other thread.
33363337
//
33373338
// In other words: any threads seen in preemptive mode are no longer interesting to us.
33383339
// if they try switch to cooperative, they would see the flag set.
3340+
#ifdef FEATURE_PERFTRACING
3341+
// Mark that the thread is currently in managed code.
3342+
thread->SaveGCModeOnSuspension();
3343+
#endif // FEATURE_PERFTRACING
33393344
if (!thread->m_fPreemptiveGCDisabled.LoadWithoutBarrier())
33403345
{
33413346
_ASSERTE(!thread->HasThreadState(Thread::TS_GCSuspendFlags));
@@ -5810,11 +5815,6 @@ void HandleSuspensionForInterruptedThread(CONTEXT *interruptedContext)
58105815
if (pThread->PreemptiveGCDisabled() != TRUE)
58115816
return;
58125817

5813-
#ifdef FEATURE_PERFTRACING
5814-
// Mark that the thread is currently in managed code.
5815-
pThread->SaveGCModeOnSuspension();
5816-
#endif // FEATURE_PERFTRACING
5817-
58185818
PCODE ip = GetIP(interruptedContext);
58195819

58205820
// This function can only be called when the interrupted thread is in

0 commit comments

Comments
 (0)