Skip to content

Bugs (with fixes) in withThread and runInUnboundThread

To quote my mail to the libraries list:

I discovered two similar bugs in Control.Concurrent:

  • In the function: 'runInUnboundThread' a thread is forked which first installs an exception handler before performing the given IO

computation. However it should first block asynchronous exceptions before forking the thread to ensure that the exception handler is always installed. In the attached patch I use the 'blockedApply' function which also ensures that the forked IO computation has the same blocked state as its parent thread.

  • There's a similar problem in the internal withThread function (which AFAICS is only called in threadWaitRead). withThead also forgets to properly block asynchronous exceptions before forking a thread which needs to install an exception handler. In this case I didn't use blockedApply but only used block because withThread is only called with 'waitFd' which only performs an FFI call which can't receive asynchronous exceptions anyway.
Trac metadata
Trac field Value
Version 6.12.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/base
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information