Bugfixes for withThread and runInUnboundThread

Bas van Dijk v.dijk.bas at gmail.com
Fri Mar 26 18:57:31 EDT 2010


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
AFAIKS 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.

Should I make a bugreport or can this be applied immediately?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: bugfixed_for_withThread_runInUnboundThread.dpatch
Type: application/octet-stream
Size: 30022 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/libraries/attachments/20100326/94acad3c/bugfixed_for_withThread_runInUnboundThread-0001.obj

More information about the Libraries mailing list