Re: FFI callback is broken in last git version
Kostirya <[email protected]> Thu, 29 Sep 2016 17:19:44 +0300
| Newsgroups | gmane.comp.lang.ml.mlton.user |
|---|---|
| Message-ID | <CAG+QnTdpm7YNxEWoF6HZkVxNe96f=2WrmFQECn6DGt6FAGwOVw@mail.gmail.com> |
2016-09-29 16:56 GMT+03:00 Matthew Fluet <[email protected]>: > > In your example, you _import "foo", but your C code defines "baz". It was a typo in the code example. > > But, other than that, I don't see anything wrong with the code, and > you should be able to pass an "int ref" to a C function, update it, > and then observe the update back in the SML code. That's right, it works in most calls, however it fails sometimes. The error only occurs on 64bit OS. > > > On Thu, Sep 29, 2016 at 9:41 AM, Kostirya <[email protected]> wrote: > > I found, thank you. > > But I do not know how to fix it. > > I'll try to describe on simplified example > > > > SML code: > > > > val foo_ffi = _import "foo" reentrant: int ref -> unit; > > > > fun foo () = > > let > > val r = ref 0 > > val _ = foo_ffi(r) > > in > > !r > > end > > > > C code: > > > > void baz (int * r) { > > *r = 10; // There is Segmentation fault !!! > > return; > > } > > > > gdb: > > #4 0x00000000004212b4 in MLton_init (argc=<error reading variable: Cannot > > access memory at address 0x7ff2ce3ef174>, > > argv=<error reading variable: Cannot access memory at address > > 0x7ff2ce3ef168>, > > s=<error reading variable: Cannot access memory at address > > 0x7ff2ce3ef160>) at platform.c:20 > > Backtrace stopped: previous frame inner to this frame (corrupt stack?) > > > > N.B. This only for 64 bit Linux. 32 bit - OK. -- You received this message because you are subscribed to the Google Groups "MLton-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. ------------------------------------------------------------------------------ _______________________________________________ MLton-user mailing list [email protected]; [email protected] https://lists.sourceforge.net/lists/listinfo/mlton-user