Skip to content

Document behaviour of throwTo to your own ThreadId

The behaviour of throwTo my_tid could be considered surprising because it seems to work exactly like throw.

Take these two tests:

main = do
    tid <- myThreadId
    
    putStrLn "Self-throw:"
    throwTo tid (ErrorCall "Hello")
    
    putStrLn "Masked self-throw:"
    uninterruptibleMask_ $ throwTo tid (ErrorCall "Hello")

Both of them raise the exception immediately and thus terminate the program. However, given the docs for throwTo and uninterruptibleMask an equally valid interpretation would be for the second test to block forever. Clarifying this might be useful.

(If you try either example in GHCi then no exception is thrown - is that a bug?)

Trac metadata
Trac field Value
Version 7.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Documentation
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