[MLton-user] Library segfault (GC_switchToThread)

Alexandre Hamez alexandre.hamez at gmail.com
Wed Feb 16 05:45:59 PST 2011


Hello,

	I've been trying to compile a library with MLton (version: 20100608 (built Tue Jun  8 16:05:08 EDT 2010 on zaphod.cs.rit.edu)) on MacOS X 10.6.5. 
	Everything works fine until I launch an executable linking with this library: it crashes with a segmentation fault, with the following stack trace:
> 	0   foo.dylib                     	0x000000010001bf92 GC_switchToThread + 34
> 	1   foo.dylib                     	0x0000000100004772 foo + 154
> 	2   a.out                         	0x0000000100000f4b main + 25
> 	3   a.out                         	0x0000000100000f10 start + 52


	I compiled the library with the following line (I've tried also with the 'archive' format):
> 		mlton -default-ann 'allowFFI true' -format library foo.sml
and the executable with the Apple GCC compiler (and also with GCC 4.5 of macports):
> 		gcc -I. main.c -L. -lfoo -L/opt/local/lib -lgmp


foo.sml:
> val e = _export "foo" : (int -> int) -> unit;
> val _ = e (fn x => x + 1)

main.c:
> #include <stdio.h>
> 
> #define PART_OF_FOO
> #include "foo.h"
> 
> int main( int argc, char** argv ) {
>   int res = foo(1);
>   printf("%d\n",res);
> 
>   return 0;
> }
> 


Am I doing something wrong? Sorry if I missed something, but I did not find any clue on the MLton website.

PS.: Why stripping 'lib' in the name of the generated library?

---------------------
Alexandre Hamez











More information about the MLton-user mailing list