summaryrefslogtreecommitdiff
path: root/src/vm
diff options
context:
space:
mode:
Diffstat (limited to 'src/vm')
-rw-r--r--src/vm/eventpipe.cpp9
-rw-r--r--src/vm/eventpipeconfiguration.cpp6
-rw-r--r--src/vm/eventpipeconfiguration.h12
3 files changed, 26 insertions, 1 deletions
diff --git a/src/vm/eventpipe.cpp b/src/vm/eventpipe.cpp
index ade5dbcfb1..cad3093d46 100644
--- a/src/vm/eventpipe.cpp
+++ b/src/vm/eventpipe.cpp
@@ -594,6 +594,15 @@ void EventPipe::WriteEventInternal(EventPipeEvent &event, EventPipeEventPayload
}
else if(s_pConfig->RundownEnabled())
{
+ // It is possible that some events that are enabled on rundown can be emitted from other threads.
+ // We're not interested in these events and they can cause corrupted trace files because rundown
+ // events are written synchronously and not under lock.
+ // If we encounter an event that did not originate on the thread that is doing rundown, ignore it.
+ if(!s_pConfig->IsRundownThread(pThread))
+ {
+ return;
+ }
+
BYTE *pData = payload.GetFlatData();
if (pData != NULL)
{
diff --git a/src/vm/eventpipeconfiguration.cpp b/src/vm/eventpipeconfiguration.cpp
index 6206bbc74f..d787956c7c 100644
--- a/src/vm/eventpipeconfiguration.cpp
+++ b/src/vm/eventpipeconfiguration.cpp
@@ -19,6 +19,7 @@ EventPipeConfiguration::EventPipeConfiguration()
m_enabled = false;
m_rundownEnabled = false;
+ m_pRundownThread = NULL;
m_pConfigProvider = NULL;
m_pSession = NULL;
m_pProviderList = new SList<SListElem<EventPipeProvider*>>();
@@ -409,6 +410,7 @@ void EventPipeConfiguration::Disable(EventPipeSession *pSession)
m_enabled = false;
m_rundownEnabled = false;
+ m_pRundownThread = NULL;
m_pSession = NULL;
}
@@ -440,8 +442,10 @@ void EventPipeConfiguration::EnableRundown(EventPipeSession *pSession)
// Build the rundown configuration.
_ASSERTE(m_pSession == NULL);
- // Enable rundown.
+ // Enable rundown and keep track of the rundown thread.
// TODO: Move this into EventPipeSession once Enable takes an EventPipeSession object.
+ m_pRundownThread = GetThread();
+ _ASSERTE(m_pRundownThread != NULL);
m_rundownEnabled = true;
// Enable tracing.
diff --git a/src/vm/eventpipeconfiguration.h b/src/vm/eventpipeconfiguration.h
index 5ac68c277e..0f500bd73a 100644
--- a/src/vm/eventpipeconfiguration.h
+++ b/src/vm/eventpipeconfiguration.h
@@ -82,6 +82,15 @@ public:
// Delete deferred providers.
void DeleteDeferredProviders();
+ // Determine if the specified thread is the rundown thread.
+ // Used during rundown to ignore events from all other threads so that we don't corrupt the trace file.
+ inline bool IsRundownThread(Thread *pThread)
+ {
+ LIMITED_METHOD_CONTRACT;
+
+ return (pThread == m_pRundownThread);
+ }
+
private:
// Get the provider without taking the lock.
@@ -111,6 +120,9 @@ private:
// True if rundown is enabled.
Volatile<bool> m_rundownEnabled;
+
+ // The rundown thread. If rundown is not enabled, this is NULL.
+ Thread *m_pRundownThread;
};
#endif // FEATURE_PERFTRACING