Skip to content

Potentially problematic data race in scheduler

!1603 (closed) revealed the following data race:

SUMMARY: ThreadSanitizer: data race rts/Capability.h:452 in stopCapability
==================
==================
WARNING: ThreadSanitizer: data race (pid=2294)
  Read of size 4 at 0x7fc63d213b00 by thread T4:
    #0 shouldYieldCapability rts/Schedule.c:642 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x000000047fe4)
    #1 scheduleYield rts/Schedule.c:666 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x000000047fe4)
    #2 schedule rts/Schedule.c:294 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x000000047fe4)
    #3 scheduleWorker rts/Schedule.c:2566 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x00000004ae6e)
    #4 workerStart rts/Task.c:445 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x000000051c04)
    #5 <null> <null> (libtsan.so.0+0x000000028d5b)

  Previous write of size 4 at 0x7fc63d213b00 by main thread (mutexes: write M8):
    #0 newReturningTask rts/Capability.c:215 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x00000002d36d)
    #1 waitForCapability rts/Capability.c:841 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x00000002d36d)
    #2 resumeThread rts/Schedule.c:2447 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x00000004a7d2)
    #3 <null> <null> (libHSbase-4.13.0.0-ghc8.9.0.20190927.so+0x00000072a16d)
    #4 scheduleWaitThread rts/Schedule.c:2549 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x00000004ae00)
    #5 rts_evalLazyIO rts/RtsAPI.c:530 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x00000003eb23)
    #6 hs_main rts/RtsMain.c:72 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x0000000421f6)
    #7 main <null> (ghc+0x000000437250)

  Location is global 'MainCapability' of size 1280 at 0x7fc63d213680 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x0000000abb00)

  Mutex M8 (0x7fc63d213ac8) created at:
    #0 pthread_mutex_init <null> (libtsan.so.0+0x00000002c81e)
    #1 initMutex rts/posix/OSThreads.c:170 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x00000007a8b7)
    #2 initCapability rts/Capability.c:259 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x00000002be5a)
    #3 moreCapabilities rts/Capability.c:416 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x00000002cb38)
    #4 initCapabilities rts/Capability.c:379 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x00000002cbe6)
    #5 initScheduler rts/Schedule.c:2642 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x00000004af6b)
    #6 hs_init_ghc rts/RtsStartup.c:237 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x000000043013)
    #7 hs_main rts/RtsMain.c:57 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x0000000421cb)
    #8 main <null> (ghc+0x000000437250)

  Thread T4 (tid=2314, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x00000002c010)
    #1 createOSThread rts/posix/OSThreads.c:137 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x00000007a82f)
    #2 startWorkerTask rts/Task.c:497 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x000000052653)
    #3 releaseCapability_ rts/Capability.c:563 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x00000002d036)
    #4 suspendThread rts/Schedule.c:2414 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x00000004a6bc)
    #5 <null> <null> (libHSbase-4.13.0.0-ghc8.9.0.20190927.so+0x00000072a13b)
    #6 scheduleWaitThread rts/Schedule.c:2549 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x00000004ae00)
    #7 rts_evalLazyIO rts/RtsAPI.c:530 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x00000003eb23)
    #8 hs_main rts/RtsMain.c:72 (libHSrts-1.0_thr-ghc8.9.0.20190927.so+0x0000000421f6)
    #9 main <null> (ghc+0x000000437250)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information