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

Wesley W. Terpstra wesley at terpstra.ca
Sat Feb 17 05:58:10 PST 2007


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). It does not inline the recursive calls,  
just remembers the termination of the recursive call. Then the  
GC.collect happens which changes what 'eor' WOULD have been.

As evidence, if I place enough statements between the GC.collect and  
the following print statement, everything works.

I think the fix is simple. The compiler has to recognize that  
MLton.GC.collect () has side-effects. How would I tell it that?




More information about the MLton mailing list