summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-10-03 15:18:48 +0000
committerBen Gamari <ben@smart-cactus.org>2020-10-24 21:00:38 -0400
commit086521f744f989a4f11585989f1304ab1333a61b (patch)
tree2079382bc81f4457f28aff1fa0bdd403abe2f61f
parent56778ab38eeb9fd683250a57c228f3821a444811 (diff)
downloadhaskell-086521f744f989a4f11585989f1304ab1333a61b.tar.gz
rts: Eliminate shutdown data race on task counters
-rw-r--r--rts/Stats.c4
-rw-r--r--rts/Task.c1
2 files changed, 5 insertions, 0 deletions
diff --git a/rts/Stats.c b/rts/Stats.c
index 80fca509ad..fcf48c3720 100644
--- a/rts/Stats.c
+++ b/rts/Stats.c
@@ -1230,6 +1230,8 @@ stat_exit (void)
{
RTSSummaryStats sum;
init_RTSSummaryStats(&sum);
+ // We'll need to refer to task counters later
+ ACQUIRE_LOCK(&all_tasks_mutex);
if (RtsFlags.GcFlags.giveStats != NO_GC_STATS) {
// First we tidy the times in stats, and populate the times in sum.
@@ -1446,6 +1448,8 @@ stat_exit (void)
stgFree(GC_coll_max_pause);
GC_coll_max_pause = NULL;
}
+
+ RELEASE_LOCK(&all_tasks_mutex);
}
/* Note [Work Balance]
diff --git a/rts/Task.c b/rts/Task.c
index 5fc2331827..c471d4afee 100644
--- a/rts/Task.c
+++ b/rts/Task.c
@@ -30,6 +30,7 @@
Task *all_tasks = NULL;
// current number of bound tasks + total number of worker tasks.
+// Locks required: all_tasks_mutex.
uint32_t taskCount;
uint32_t workerCount;
uint32_t currentWorkerCount;