The problem in this case is that the C code receives a pointer `x' to a
GC-managed object, and the object at that memory moves during the
callback to filler(), so that memcpy(x, ....) copies to the wrong
place.

Ahhh, I should have figured that. Thanks!

Assuming that your C code will remain oblivious to GC, you'll have to
change the call to myfunc2() to pass a reference to an object that is
either not GC-managed or won't be moved by a GC (i.e., allocated using
'atomic-interior mode):

Yes, it works great with make-f64vector/immobile, thanks!

As a general inquiry, what are the rules for GC about
collecting malloc-ed objects? Can I be sure that it does
not collect my vector while the C call or callback who uses
it is still executing?

(I see that I can be sure in this case, because "vec" is used
after the "myfunc2" call, but that is not always the case.)

Best regards,

Dmitry
____________________
 Racket Users list:
 http://lists.racket-lang.org/users

Reply via email to