[MLton] MLton.GC.collect hangs when using MLton.Finalizable

Wesley W. Terpstra wesley at terpstra.ca
Sat Feb 17 06:59:13 PST 2007


On Feb 17, 2007, at 3:18 PM, Matthew Fluet wrote:
> The "bug" is in your usage of Finalizable
I agree, but I think the bug is that the Ring is not thread-safe. The  
fact that it could unlink at any time is fine.

> But, you immediately drop all references to the *container* b, so  
> at any time, the finalizer could run, and remove b' from the ring.
Which is what I wanted to happen. The "problem" was that MLton  
reordered instructions so that the end-of-ring reference was formed  
before the GC call which preceded it (and should remove it).

> In particular, the finalizer could run *during* the loop in fold;  
> where it removes the end-of-ring reference, leaving fold to run in  
> an an infinite loop.
That's not what was happening... However, I fully agree this was a  
latent bug, closed by adding MLton.Thread.atomically.

At any rate, sorry to have wasted your time on this and thanks for  
taking a look. I should probably increase my bug reporting barrier  
wrt MLton.




More information about the MLton mailing list