[project @ 2004-09-28 15:08:58 by simonmar]
authorsimonmar <unknown>
Tue, 28 Sep 2004 15:08:58 +0000 (15:08 +0000)
committersimonmar <unknown>
Tue, 28 Sep 2004 15:08:58 +0000 (15:08 +0000)
commit07291441614c93357b813f7d4d007e9c32636582
treeaf5d9d6ab3ec97ac5ee179ec4ad2e0641cb89d27
parentc6226d8a6cbdb568343724fe2e1880d9683d37d9
[project @ 2004-09-28 15:08:58 by simonmar]
rts_evalStableIO: set rtsApiCapability to NULL *before* calling
scheduleWaitThread, matching the way the other eval_* functions do
this.

The previous way lead to a suble race condition:
  - thread A calls rts_evalIO, enters scheduleWaitThread()
    (rtsApiCapability == NULL).
  - thread B calls rts_evalStableIO, creates a main thread and enters
    scheduleWaitThread() (rtsApiCapability == &MainCapability)
  - thread A exits scheduleWaitThread, sees that rtsApiCapability is
    non-NULL, and calls releaseCapability() on it.  This is bogus,
    because thread A doesn't actually hold the capability, and we've
    done a double-release.

This scenario leads to assertion failures in a debug threaded RTS, and
probably crashes in a non-debug threaded RTS.

MERGE TO STABLE
ghc/rts/RtsAPI.c