[MLton-user] Re: CML and foreign code
Ivan Tomac
ivan.tomac at gmail.com
Wed Sep 28 22:45:11 PDT 2011
Done some more testing very briefly. Here's an example that crashes.
I've currently tested this with the head version of MLton from SVN
built using Mingw build of GCC 4.6.1, 32-bit, running on Vista 64 SP2.
Will try to test later with the latest released version of MLton too,
just in case.
Test code for files test.sml, ctest.c, ctest.h and test.mlb is below.
To compile the tests I ran
mlnlffigen -linkage archive -mlbfile ffi.mlb -dir ffi ctest.h
mlton -link-opt "-ldl.dll" test.mlb ctest.c
The code crashes unless I comment out RunCML.doit and call main directly.
(* test.sml *)
fun main () = F_blorf.f' ()
val _ = RunCML.doit(main, NONE)
/* ctest.c */
#include <windows.h>
void blorf(void)
{
MessageBoxA(NULL, "blorf", "blorf", MB_OK);
}
/* ctest.h */
void blorf(void);
(* test.mlb *)
$(SML_LIB)/basis/basis.mlb
$(SML_LIB)/basis/mlton.mlb
$(SML_LIB)/cml/cml.mlb
ffi/ffi.mlb
test.sml
On Thu, Sep 29, 2011 at 9:27 AM, Ivan Tomac <ivan.tomac at gmail.com> wrote:
> Are there any known issues or guidelines on using CML with foreign code?
>
> I had previously ran into problems with that in SML/NJ under OS X and
> raised a bug report but MLton code seemed to be running fine. Until I
> tried running it on Windows where it now crashes, unless I comment out
> the CML code. The workaround that had worked with SML/NJ, which was to
> mask off the alarm signal didn't work in MLton. I also tried the
> doAtomic functions from cml/util/critical.sml, that didn't fix it
> either.
>
> It's possible this is a different problem and that perhaps I have a
> bug in my C code. Can't tell for sure yet, will debug this later and
> try to narrow things down to a trivial example.
> But before I do that I'm just wondering if there are any known issues
> or rules I may not be aware of?
>
> Ivan
>
More information about the MLton-user
mailing list