summaryrefslogtreecommitdiff
path: root/src/vm
diff options
context:
space:
mode:
authorBrian Robbins <brianrob@microsoft.com>2018-03-03 20:56:43 -0800
committerGitHub <noreply@github.com>2018-03-03 20:56:43 -0800
commita6a3d382d9a5fabeda6983f90226939228a14cfe (patch)
tree6fe0159a2c19b9796b620dfff6901449ab3c2efe /src/vm
parent3ddf5123ab43d40c8458f005554c43a632ac2c71 (diff)
downloadcoreclr-a6a3d382d9a5fabeda6983f90226939228a14cfe.tar.gz
coreclr-a6a3d382d9a5fabeda6983f90226939228a14cfe.tar.bz2
coreclr-a6a3d382d9a5fabeda6983f90226939228a14cfe.zip
Fix use of EventPipeConfiguration after it has been freed on shutdown. (#16704)
Diffstat (limited to 'src/vm')
-rw-r--r--src/vm/eventpipe.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/vm/eventpipe.cpp b/src/vm/eventpipe.cpp
index e413713053..ab137388dd 100644
--- a/src/vm/eventpipe.cpp
+++ b/src/vm/eventpipe.cpp
@@ -237,7 +237,10 @@ void EventPipe::Shutdown()
}
CONTRACTL_END;
- // We are shutting down, so if diasabling EventPipe throws, we need to move along anyway
+ // Mark tracing as no longer initialized.
+ s_tracingInitialized = false;
+
+ // We are shutting down, so if disabling EventPipe throws, we need to move along anyway.
EX_TRY
{
Disable();
@@ -245,16 +248,19 @@ void EventPipe::Shutdown()
EX_CATCH { }
EX_END_CATCH(SwallowAllExceptions);
- if(s_pConfig != NULL)
- {
- delete(s_pConfig);
- s_pConfig = NULL;
- }
- if(s_pBufferManager != NULL)
- {
- delete(s_pBufferManager);
- s_pBufferManager = NULL;
- }
+ // Save pointers to the configuration and buffer manager.
+ EventPipeConfiguration *pConfig = s_pConfig;
+ EventPipeBufferManager *pBufferManager = s_pBufferManager;
+
+ // Set the static pointers to NULL so that the rest of the EventPipe knows that they are no longer available.
+ // Flush process write buffers to make sure other threads can see the change.
+ s_pConfig = NULL;
+ s_pBufferManager = NULL;
+ FlushProcessWriteBuffers();
+
+ // Free the configuration and buffer manager.
+ delete(pConfig);
+ delete(pBufferManager);
}
void EventPipe::Enable(