Asynchronous exceptions and laziness bugs in Control.Concurrent.QSem/QSemN

Hello, after discovering the bugs regarding asynchronous exceptions and laziness in Data.Unique and Control.Concurrent.SampleVar I became a bit suspicious about the other concurrency mechanisms. It looks like Control.Concurrent.Chan is safe because it uses modifyMVar_ internally which performs the necessary block. Control.Concurrent.QSem and QSemN are not alright however! They both suffer the same bugs: * Potential dead-lock due to not blocking asynchronous exceptions. * Potential space-leak because of lazily putting numeric expression in a MVar. The attached patch fixes these bugs. regards, Bas

Looks good to me. Thanks.
On Thu, Mar 18, 2010 at 1:54 PM, Bas van Dijk
Hello,
after discovering the bugs regarding asynchronous exceptions and laziness in Data.Unique and Control.Concurrent.SampleVar I became a bit suspicious about the other concurrency mechanisms.
It looks like Control.Concurrent.Chan is safe because it uses modifyMVar_ internally which performs the necessary block.
Control.Concurrent.QSem and QSemN are not alright however! They both suffer the same bugs:
* Potential dead-lock due to not blocking asynchronous exceptions. * Potential space-leak because of lazily putting numeric expression in a MVar.
The attached patch fixes these bugs.
regards,
Bas
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

This was coincidentaly widely discussed at Galois recently, in two talks: * http://www.galois.com/~dons/talks/strict-concurrency-feb-26-2010/strict-conc... * http://www.galois.com/~dons/talks/jl-march-2010-async.pdf So good to see you're looking at these. bos:
Looks good to me. Thanks.
On Thu, Mar 18, 2010 at 1:54 PM, Bas van Dijk
wrote: Hello,
after discovering the bugs regarding asynchronous exceptions and laziness in Data.Unique and Control.Concurrent.SampleVar I became a bit suspicious about the other concurrency mechanisms.
It looks like Control.Concurrent.Chan is safe because it uses modifyMVar_ internally which performs the necessary block.
Control.Concurrent.QSem and QSemN are not alright however! They both suffer the same bugs:
* Potential dead-lock due to not blocking asynchronous exceptions. * Potential space-leak because of lazily putting numeric expression in a MVar.
The attached patch fixes these bugs.
regards,
Bas
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

I just created a ticket for this so it's not forgotten:
http://hackage.haskell.org/trac/ghc/ticket/3944
Bas
On Thu, Mar 18, 2010 at 9:54 PM, Bas van Dijk
Hello,
after discovering the bugs regarding asynchronous exceptions and laziness in Data.Unique and Control.Concurrent.SampleVar I became a bit suspicious about the other concurrency mechanisms.
It looks like Control.Concurrent.Chan is safe because it uses modifyMVar_ internally which performs the necessary block.
Control.Concurrent.QSem and QSemN are not alright however! They both suffer the same bugs:
* Potential dead-lock due to not blocking asynchronous exceptions. * Potential space-leak because of lazily putting numeric expression in a MVar.
The attached patch fixes these bugs.
regards,
Bas
participants (3)
-
Bas van Dijk
-
Bryan O'Sullivan
-
Don Stewart