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

Wesley W. Terpstra wesley at terpstra.ca
Sat Feb 17 06:25:49 PST 2007


On Feb 17, 2007, at 2:58 PM, Wesley W. Terpstra wrote:
> On Feb 17, 2007, at 2:33 PM, Wesley W.Terpstra wrote:
>> Compile the attached program and watch it hang in MLton.GC.collect.
>
> Ahh. It's actually going into an infinite loop in Ring.fold. I  
> believe what's happening is that MLton is inlining the two "sum a"  
> calls and then detecting the common sub-expression where I record  
> the value 'eor' (end-of-ring).

I see that declaring garbage collection as a barrier to common sub- 
expression elimination is a problem, since it can happen at any  
allocation. While I still find the behaviour surprising, I no longer  
think its a bug that would be desirable to fix.

At any rate, this only mattered b/c my Ring implementation is not  
thread-safe. Even if the common sub-expression didn't happen, there  
would still be a problem: If I am walking the ring and a GC occurs, I  
could get trapped on a removed link. Wrapping the add/remove/fold  
methods in a MLton.Thread.atomically makes the problem go away.

So, I guess you can ignore this "bug" report.




More information about the MLton mailing list