conc059 is racy
conc059 testcase sometimes fails with additional output:
--- concurrent/should_run/conc059.run/conc059.stdout.normalised 2021-01-05 03:12:02.393535003 +0000 +++ concurrent/should_run/conc059.run/conc059.run.stdout.normalised 2021-01-05 03:12:02.393535003 +0000 @@ -1,3 +1,13 @@ exiting... 500000 +hello +hello +hello +hello +hello +hello +hello +hello +hello +hello exited.
Looking at the test itself, this not surprising: the test kicks off several Haskell threads which print "hello" before returning (which should only happen after the main thread has returned and the RTS has been shut down). I suspect that the delay in the Haskell threads (0.5 s) is too short. Consequently, if the main thread gets descheduled then the Haskell threads will run to completion before the main thread returns and tears down the RTS. I can see two ways forward here:
- Increase the Haskell thread delay (perhaps by a factor of 10)
- Eliminate the print in the Haskell threads (although this would mean that we wouldn't know when the timings are wrong, potentially defeating the point of the test)
Incidentally this is not the first racy behavior I have noticed in
conc059: I fixed a related problem in 543dfaab.