summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mason <davmason@microsoft.com>2019-09-18 13:19:36 -0700
committerGleb Balykov <g.balykov@samsung.com>2020-03-25 15:29:41 +0300
commit24f9e9515bfbe4520d11cd0741724647c23a943b (patch)
treebc24c2bb2f3c8b855a7f87a27b928b204eb9c2d7
parent00aa747d9d392c0b202dedbebee26d15573d35dc (diff)
downloadcoreclr-24f9e9515bfbe4520d11cd0741724647c23a943b.tar.gz
coreclr-24f9e9515bfbe4520d11cd0741724647c23a943b.tar.bz2
coreclr-24f9e9515bfbe4520d11cd0741724647c23a943b.zip
Prevent freeing of the profiler on process shutdown.
-rw-r--r--src/vm/ceemain.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/vm/ceemain.cpp b/src/vm/ceemain.cpp
index 8a5bb4f4e6..01dae00872 100644
--- a/src/vm/ceemain.cpp
+++ b/src/vm/ceemain.cpp
@@ -1481,16 +1481,14 @@ void STDMETHODCALLTYPE EEShutDownHelper(BOOL fIsDllUnloading)
// callbacks from coming into the profiler even after Shutdown() has been called.
// See https://github.com/dotnet/coreclr/issues/22176 for an example of how that
// happens.
- // Callbacks will be prevented when ProfilingAPIUtility::Terminate() changes the state
- // to detached, which occurs shortly afterwards. It might be kinder to make the detaching
- // transition before calling Shutdown(), but if we do we'd have to be very careful not
- // to break profilers that were relying on being able to call various APIs during
- // Shutdown(). I suspect this isn't something we'll ever do unless we get complaints.
+ //
+ // To prevent issues when profilers are attached we intentionally skip freeing the
+ // profiler here. Since there is no guarantee that the profiler won't be accessed after
+ // we free it (e.g. through callbacks or ELT hooks), we can't safely free the profiler.
if (CORProfilerPresent())
{
- // If EEShutdown is not being called due to a ProcessDetach event, so
- // the profiler should still be present
- if (!g_fProcessDetach)
+ // Don't call back in to the profiler if we are being torn down, it might be unloaded
+ if (!fIsDllUnloading)
{
BEGIN_PIN_PROFILER(CORProfilerPresent());
GCX_PREEMP();
@@ -1499,9 +1497,6 @@ void STDMETHODCALLTYPE EEShutDownHelper(BOOL fIsDllUnloading)
}
g_fEEShutDown |= ShutDown_Profiler;
-
- // Free the interface objects.
- ProfilingAPIUtility::TerminateProfiling();
}
#endif // PROFILING_SUPPORTED