joeyadams/haskell-chat-server-example — comment on commit 94c128177c3af8c13b4b3f7b36256e11078acabe
File: Main.hs line 133
By gregorycollins:

I think you have a threading bug here w.r.t. asynchronous exceptions; if the thread is killed before your exception handler is installed, the MVar never gets written to. You need to mask asynchronous exceptions before you fork; the usual idiom for this is:

mask $ \restore -> forkIO $ try (restore io) >> tryPutMVar done ()