Skip to content

Commit

Permalink
only set THREAD_IS_SUSPENDED if we are truly doing an async stack walk (
Browse files Browse the repository at this point in the history
  • Loading branch information
davmason committed Oct 18, 2019
1 parent e285505 commit ef3180c
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/vm/proftoeeinterfaceimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8285,15 +8285,27 @@ HRESULT ProfToEEInterfaceImpl::DoStackSnapshot(ThreadID thread,
// with destructors.
AVInRuntimeImplOkayHolder AVOkay;

DWORD asyncFlags = 0;
if (pThreadToSnapshot != pCurrentThread)
{
asyncFlags |= ALLOW_ASYNC_STACK_WALK;
if (!g_profControlBlock.fProfilerRequestedRuntimeSuspend)
{
// THREAD_IS_SUSPENDED signals to the stack walker that the
// thread is interrupted at an arbitrary point and to be careful
// not to cause a deadlock. If the profiler suspended the runtime,
// then we know the threads are at a safe place and we can walk all the threads.
asyncFlags |= THREAD_IS_SUSPENDED;
}
}

hr = DoStackSnapshotHelper(
pThreadToSnapshot,
&data,
HANDLESKIPPEDFRAMES |
FUNCTIONSONLY |
NOTIFY_ON_U2M_TRANSITIONS |
((pThreadToSnapshot == pCurrentThread) ?
0 :
ALLOW_ASYNC_STACK_WALK | THREAD_IS_SUSPENDED) |
asyncFlags |
THREAD_EXECUTING_MANAGED_CODE |
PROFILER_DO_STACK_SNAPSHOT |
ALLOW_INVALID_OBJECTS, // stack walk logic should not look at objects - we could be in the middle of a gc.
Expand Down

0 comments on commit ef3180c

Please sign in to comment.