[MLton] Re: [MLton-user] ffi newbie (fwd)

Matthew Fluet fluet at tti-c.org
Thu Sep 6 20:22:53 PDT 2007


On Thu, 6 Sep 2007, Matthew Fluet wrote:
>  I've got the segfault in the program narrowed down to 4 small C and ML
> files.

I whittled the program down a little smaller, and posted the code at
   http://www.mlton.org/TemporaryUpload.
This doesn't require any extra libraries.

> It is a very strange one.  In another part of the code I'm using the GLPK
> linear programming C library.
> To deallocate storage I'm using the F = MLton.Finalizable structure.  Oddly,
> if
> I call [F.new], I get the segfault, but not without it.

Using finalizers introduces a signal handler for the GC signal, which in 
turn introduces some threads into the program. (Calling an _export-ed 
function also introduces another thread of control into the program.)  It 
is not entirely surprising that there are weird interactions between 
finalizers, the signal handler thread, and the _export-ed functions, 
though I can't immediately see why.

In any case, I see the segfault on both amd64-linux and x86-darwin, with 
both the native and C codegens.  I don't think that there is anything 
wrong the the SML or C code, so I think it is probably a compiler bug 
somwhere.  I also see the segfault with MLton 20051202, which suggests 
that it isn't necessarily something introduced by the runtime changes 
since the previous release.

I'm out of town until Tuesday, so I don't think this will be fixed 
immediately.




More information about the MLton mailing list