RTS: data race in pthread ticker
As reported by the failing nightly tsan job: https://gitlab.haskell.org/ghc/ghc/-/jobs/857535
WARNING: ThreadSanitizer: data race (pid=118410)
Write of size 1 at 0x7f8f6aaf1614 by main thread:
#0 exitTicker rts/posix/ticker/Pthread.c:259 (libHSrts-1.0.2-ghc9.3.20211115.so+0x000000080128)
#1 exitTimer rts/Timer.c:209 (libHSrts-1.0.2-ghc9.3.20211115.so+0x00000005b5f7)
#2 hs_exit_ rts/RtsStartup.c:478 (libHSrts-1.0.2-ghc9.3.20211115.so+0x00000004cda0)
#3 shutdownHaskellAndExit rts/RtsStartup.c:640 (libHSrts-1.0.2-ghc9.3.20211115.so+0x00000004d465)
#4 hs_main rts/RtsMain.c:99 (libHSrts-1.0.2-ghc9.3.20211115.so+0x00000004c349)
#5 main <null> (ghc-pkg-9.3.20211115+0x000000479384)
Previous read of size 1 at 0x7f8f6aaf1614 by thread T1:
#0 itimer_thread_func rts/posix/ticker/Pthread.c:112 (libHSrts-1.0.2-ghc9.3.20211115.so+0x00000007fc0b)
#1 <null> <null> (libtsan.so.0+0x000000024459)
Location is global 'exited' of size 1 at 0x7f8f6aaf1614 (libHSrts-1.0.2-ghc9.3.20211115.so+0x0000000b3614)
Thread T1 'ghc_ticker' (tid=118412, running) created by main thread at:
#0 pthread_create <null> (libtsan.so.0+0x000000027e9d)
#1 initTicker rts/posix/ticker/Pthread.c:215 (libHSrts-1.0.2-ghc9.3.20211115.so+0x00000007ff26)
#2 initTimer rts/Timer.c:180 (libHSrts-1.0.2-ghc9.3.20211115.so+0x00000005b1fa)
#3 hs_init_ghc rts/RtsStartup.c:295 (libHSrts-1.0.2-ghc9.3.20211115.so+0x00000004d088)
#4 hs_main rts/RtsMain.c:57 (libHSrts-1.0.2-ghc9.3.20211115.so+0x00000004c2db)
#5 main <null> (ghc-pkg-9.3.20211115+0x000000479384)
SUMMARY: ThreadSanitizer: data race rts/posix/ticker/Pthread.c:259 in exitTicker