From: Brian Robbins Date: Sun, 4 Mar 2018 04:56:43 +0000 (-0800) Subject: Fix use of EventPipeConfiguration after it has been freed on shutdown. (#16704) X-Git-Tag: accepted/tizen/unified/20190422.045933~2778 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a6a3d382d9a5fabeda6983f90226939228a14cfe;p=platform%2Fupstream%2Fcoreclr.git Fix use of EventPipeConfiguration after it has been freed on shutdown. (#16704) --- diff --git a/src/vm/eventpipe.cpp b/src/vm/eventpipe.cpp index e413713..ab13738 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(