This is re my posting under the subject "Weak pointers,garbage collection & deadlocks" onglasgow-haskell-users.Basically, the problem is that finaliser threads thatthe next GC would generate aren't taken into accountwhen determining whether there are any more threads torun.I attach a program reproducing the error.
Edited
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items
0
Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Linked items
0
Link issues together to show that they're related or that one is blocking others.
Learn more.
Logged In: YES user_id=10359Actually, I think, the situation is even worse than I firstthought. When in the example program that I attachedearlier you enable the `gcThread', the program will behavecorrectly, but this is unfortunately *not* guaranteed.If you are unlucky, you'll get an ``thread blockedindefinitely'' instead. The reason seems to be is that theMVar on which the main thread blocks is only accessible viathe finaliser.There seems to be a race condition here. The analysis inthis comment is based on my observation in the largerprogram that pointed me to the problem, but the program isquite complex, so I might have misinterpreted something.
Logged In: YES user_id=10359PS: The problem mentioned in the last comment can be solvedby using a StablePtr on the MVar, which is freed in thefinalisers - all quite yucky.
Logged In: YES user_id=48280Fixed: now if we get a deadlock, we try a major GC and if this creates any threads we carry on.Note that frequently relying on this behaviour is likely to be inefficient because of the forced major GC.