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

Matthew Fluet fluet at tti-c.org
Sat Feb 17 06:18:51 PST 2007

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). 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?

The GC_collect primitive is already a side-effecting primitive.

More information about the MLton mailing list