Weak pointers, garbage collection & deadlocks
Manuel M. T. Chakravarty
Sat, 02 Jun 2001 17:33:42 +1000
While using weak pointers and concurrency together, I became
convinced that before issuing the ``no threads to run:
infinite loop or deadlock?'' error message, the RTS should
perform a GC. The reason is that the GC may run some
finalisers, which in turn may unlock some threads.
The concrete scenario that I have is that I use a finaliser
to close a stream when the handle that provides input to
that stream dies. Now if the only other thread is a
consumer of that stream that waits for it to close, then
this thread can't run before the next GC is performed and
runs the finaliser.