
4 May
2012
4 May
'12
10:18 a.m.
On 4 May 2012 14:12, Simon Marlow
The forked thread is deadlocked, so the MVar is considered unreachable and the main thread is also unreachable. Hence both threads get sent the exception.
The RTS does this analysis using the GC, tracing the reachable objects starting from the roots. It then send an exception to any threads which were not reachable, which in this case is both the main thread and the child, since neither is reachable.
We (the user) knows that waking up the child thread will unblock the main thread, but the RTS doesn't know this, and it's not clear how it could find out easily (i.e. without multiple scans of the heap).
Thanks Simon, I learned something new today. Cheers, Bas