Data race during RTS shutdown
While looking at !1603 (closed):
==================
==================
WARNING: ThreadSanitizer: data race (pid=4596)
Write of size 8 at 0x00000090d6e8 by thread T6 (mutexes: write M16):
#0 stat_endGC rts/Stats.c:400 (T10296b+0x000000734e22)
#1 GarbageCollect rts/sm/GC.c:883 (T10296b+0x00000074cacb)
#2 scheduleDoGC rts/Schedule.c:1810 (T10296b+0x00000072d5e5)
#3 schedule rts/Schedule.c:552 (T10296b+0x00000072e977)
#4 scheduleWorker rts/Schedule.c:2572 (T10296b+0x0000007316be)
#5 workerStart rts/Task.c:445 (T10296b+0x0000007382d5)
#6 <null> <null> (libtsan.so.0+0x000000028d5b)
Previous read of size 8 at 0x00000090d6e8 by main thread:
#0 stat_startExit rts/Stats.c:273 (T10296b+0x000000734663)
#1 hs_exit_ rts/RtsStartup.c:380 (T10296b+0x000000729719)
#2 shutdownHaskellAndExit rts/RtsStartup.c:562 (T10296b+0x000000729f65)
#3 hs_main rts/RtsMain.c:99 (T10296b+0x000000728d7c)
#4 main <null> (T10296b+0x000000412f71)
Location is global 'stats' of size 320 at 0x00000090d660 (T10296b+0x00000090d6e8)
Mutex M16 (0x0000009103c0) created at:
#0 pthread_mutex_init <null> (libtsan.so.0+0x00000002c81e)
#1 initMutex rts/posix/OSThreads.c:170 (T10296b+0x00000075d2b7)
#2 initStorage rts/sm/Storage.c:148 (T10296b+0x0000007573fb)
#3 hs_init_ghc rts/RtsStartup.c:245 (T10296b+0x000000729b60)
#4 hs_main rts/RtsMain.c:57 (T10296b+0x000000728d0b)
#5 main <null> (T10296b+0x000000412f71)
Thread T6 (tid=4603, running) created by thread T4 at:
#0 pthread_create <null> (libtsan.so.0+0x00000002c010)
#1 createOSThread rts/posix/OSThreads.c:137 (T10296b+0x00000075d22f)
#2 startWorkerTask rts/Task.c:497 (T10296b+0x000000738cea)
#3 releaseCapability_ rts/Capability.c:568 (T10296b+0x000000722cf7)
#4 suspendThread rts/Schedule.c:2420 (T10296b+0x000000730ea4)
#5 <null> <null> (T10296b+0x00000068bf11)
#6 scheduleWorker rts/Schedule.c:2572 (T10296b+0x0000007316be)
#7 workerStart rts/Task.c:445 (T10296b+0x0000007382d5)
#8 <null> <null> (libtsan.so.0+0x000000028d5b)
SUMMARY: ThreadSanitizer: data race rts/Stats.c:400 in stat_endGC