summaryrefslogtreecommitdiff
path: root/src/vm
diff options
context:
space:
mode:
authorDavid Mason <davmason@microsoft.com>2019-10-21 13:57:30 -0700
committerGitHub <noreply@github.com>2019-10-21 13:57:30 -0700
commita43e0c2108d27cc88a22a9881ce5aaaa690a1d65 (patch)
tree621ab0d01ff909b620c46699ad338ed33431d812 /src/vm
parent89091b51f3a4ececbf2af2e9fff6f9400efe8191 (diff)
downloadcoreclr-a43e0c2108d27cc88a22a9881ce5aaaa690a1d65.tar.gz
coreclr-a43e0c2108d27cc88a22a9881ce5aaaa690a1d65.tar.bz2
coreclr-a43e0c2108d27cc88a22a9881ce5aaaa690a1d65.zip
[Release/3.1] Fixes for profiler stack sampling (#27300)
* only set THREAD_IS_SUSPENDED if we are truly doing an async stack walk (#26985) * Use a new COR_PRF_SUSPEND_FOR_PROFILER in ICorProfilerCallback::RuntimeThreadSuspended() when requested by profiler (#27041) Fixes https://github.com/dotnet/coreclr/issues/26576
Diffstat (limited to 'src/vm')
-rw-r--r--src/vm/proftoeeinterfaceimpl.cpp18
-rw-r--r--src/vm/threadsuspend.cpp2
2 files changed, 17 insertions, 3 deletions
diff --git a/src/vm/proftoeeinterfaceimpl.cpp b/src/vm/proftoeeinterfaceimpl.cpp
index cff17213a7..e0caccf4a2 100644
--- a/src/vm/proftoeeinterfaceimpl.cpp
+++ b/src/vm/proftoeeinterfaceimpl.cpp
@@ -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.
diff --git a/src/vm/threadsuspend.cpp b/src/vm/threadsuspend.cpp
index 9c0af1f913..a47812ba7d 100644
--- a/src/vm/threadsuspend.cpp
+++ b/src/vm/threadsuspend.cpp
@@ -3762,6 +3762,8 @@ COR_PRF_SUSPEND_REASON GCSuspendReasonToProfSuspendReason(ThreadSuspend::SUSPEND
return COR_PRF_SUSPEND_FOR_INPROC_DEBUGGER;
case ThreadSuspend::SUSPEND_FOR_GC_PREP:
return COR_PRF_SUSPEND_FOR_GC_PREP;
+ case ThreadSuspend::SUSPEND_FOR_PROFILER:
+ return COR_PRF_SUSPEND_FOR_PROFILER;
}
}
#endif // PROFILING_SUPPORTED