Matthew,

On 03/15/2018 04:22 AM, Matthew Flatt wrote:
At Wed, 14 Mar 2018 21:56:05 +0300, Dmitry Pavlov wrote:
I suspect that "my-callback" or something linked to it are moved
in memory by the garbage collector, and the pointer kept by
the C library is no longer valid. In the first simpler
case, that does not happen because it sets and uses the
callback in the single FFI call, right?

Callbacks are a kind of special case, and you don't have to worry about
them moving. (I'll add that to the documentation.) You only have to
worry about keeping them from being GCed.

Oh, OK. I was disoriented by the manual which has "callbacks" and
"moved in memory" in the same sentence.

Thank you very much for the incredibly detailed example program!
I actually had a multiple (double) registration of the callback
function, but the second registration was turned off and
my program still crashed.

If the issue isn't about multiple registrations, then my only guess is
that the box you're using doesn't remain reachable.

In fact, it was a silly mistake: I passed #:keep to the wrong
_fun -- in terms of the example program, in set-callback
instead of _callback.

Once I fixed that, everything got back on track.



Best regards,

Dmitry

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to