diff options
author | David Mason <davmason@microsoft.com> | 2019-09-18 13:19:36 -0700 |
---|---|---|
committer | Alexander Soldatov/AI Compiler Lab /SRR/Staff Engineer/삼성전자 <soldatov.a@samsung.com> | 2019-10-07 11:59:33 +0300 |
commit | 8576ccc6bc33d359c65d8f04eb8a105256301315 (patch) | |
tree | 05db2b204a4a281505fd736c0648d2a36eaa17e6 /src/vm/ceemain.cpp | |
parent | de564f4307b36f21f30d428d53ac71b5d96d4710 (diff) | |
download | coreclr-8576ccc6bc33d359c65d8f04eb8a105256301315.tar.gz coreclr-8576ccc6bc33d359c65d8f04eb8a105256301315.tar.bz2 coreclr-8576ccc6bc33d359c65d8f04eb8a105256301315.zip |
Prevent freeing of the profiler on process shutdown.
Diffstat (limited to 'src/vm/ceemain.cpp')
-rw-r--r-- | src/vm/ceemain.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/vm/ceemain.cpp b/src/vm/ceemain.cpp index 508693767f..8f2c46fbc5 100644 --- a/src/vm/ceemain.cpp +++ b/src/vm/ceemain.cpp @@ -1470,16 +1470,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(); @@ -1488,9 +1486,6 @@ void STDMETHODCALLTYPE EEShutDownHelper(BOOL fIsDllUnloading) } g_fEEShutDown |= ShutDown_Profiler; - - // Free the interface objects. - ProfilingAPIUtility::TerminateProfiling(); } #endif // PROFILING_SUPPORTED |