summaryrefslogtreecommitdiff
path: root/rts/Trace.h
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-12-18 10:14:09 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-03-02 17:29:05 -0500
commit8188adf0f1a0482c269d1eb6350dd91dddc9ed29 (patch)
tree89d265d5212f9c5dcbf4db0ac0ab42234d1eb164 /rts/Trace.h
parent5d7978df2f23ba125adacbe371188f99debdbb43 (diff)
downloadhaskell-8188adf0f1a0482c269d1eb6350dd91dddc9ed29.tar.gz
eventlog: Fix various races
Previously the eventlog infrastructure had a couple of races that could pop up when using the startEventLog/endEventLog interfaces. In particular, stopping and then later restarting logging could result in data preceding the eventlog header, breaking the integrity of the stream. To fix this we rework the invariants regarding the eventlog and generally tighten up the concurrency control surrounding starting and stopping of logging. We also fix an unrelated bug, wherein log events from disabled capabilities could end up never flushed.
Diffstat (limited to 'rts/Trace.h')
-rw-r--r--rts/Trace.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/rts/Trace.h b/rts/Trace.h
index cad83363d3..08b42fe9bd 100644
--- a/rts/Trace.h
+++ b/rts/Trace.h
@@ -8,7 +8,7 @@
#pragma once
-#include "rts/EventLogFormat.h"
+#include "eventlog/EventLog.h"
#include "sm/NonMovingCensus.h"
#include "Capability.h"
@@ -616,6 +616,18 @@ INLINE_HEADER void traceCapDisable(Capability *cap STG_UNUSED)
{
traceCapEvent(cap, EVENT_CAP_DISABLE);
dtraceCapDisable((EventCapNo)cap->no);
+
+ // Ensure that the eventlog buffer is flushed since otherwise its events
+ // may never make it to the output stream.
+ // See Note [Eventlog concurrency].
+#if defined(TRACING)
+ if (eventlog_enabled) {
+ flushLocalEventsBuf(cap);
+ }
+# else
+ flushLocalEventsBuf(cap);
+#endif
+
}
INLINE_HEADER void traceEventThreadWakeup(Capability *cap STG_UNUSED,