Re: FFI callback is broken in last git version
Kostirya <[email protected]> Thu, 29 Sep 2016 16:41:21 +0300
| Newsgroups | gmane.comp.lang.ml.mlton.user |
|---|---|
| Message-ID | <CAG+QnTeLp6vUf0K0=ufx14qT4N9dbFZ1vzOPg91mXvDmXDpu_w@mail.gmail.com> |
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.
2016-09-29 14:56 GMT+03:00 Matthew Fluet <[email protected]>:
> On Thu, Sep 29, 2016 at 7:14 AM, Kostirya <[email protected]> wrote:
> > Another question.
> > My 32byt application is work fine - "reentrant" helped.
> > But I have problems with 64bit version: segmentation fault is sometimes.
> > Tell me, please, how it is possible to catch.
> > As I can enable debug symbol for coredump?
>
> Sure, "mlton -debug true z.mlb" will compile the generated .c and .s
> files with "-g" and will link with a runtime system itself compiled
> with "-g". The latter won't be as helpful if you don't have the MLton
> sources around, so best to use with a local build of the compiler.
>
> >
> > 2016-09-29 10:54 GMT+03:00 Florian Weimer <[email protected]>:
> >>
> >> > By the way, what does "reentrant" do?
> >> > I guess it turns GC, among other things. At least this seemed to me
> when
> >> > I
> >> > was exploring rare segmentation faults with MLton 20130715.
> >>
> >> It performs additional bookkeeping required so that C code can safely
> >> call back into SML code. This has some overhead, so it is not enabled
> >> by default.
> >>
> >> --
> >> 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
> >
> >
> > --
> > 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
> >
>
> --
> 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
>
--
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