[racket-dev] occasional seg faults when calling C routine

From: John Clements (clements at brinckerhoff.org)
Date: Fri Oct 21 17:10:03 EDT 2011

I'm getting occasional (non-reliably-reproducible) seg faults when calling a C routine that copies bits from one place to another.

My working assumption is that the buffer is getting moved by GC in between the computation of the pointers and the actual ffi invocation, though that's a fairly tight window, given that the pointers are computed directly as the arguments to the ffi call. I have some questions to see whether I'm understanding what's going on:

1) Is it true that GCs cannot occur during the evaluation of ffi code on the main thread?
2) Is there any way either to disable GC briefly or to prevent an object from being moved?
3) lacking this, (and assuming that #1 is true), it looks like the right thing is to use malloc-immobile cell so that the pointer lookup can happen inside of the C code. Does this sound correct?

Many thanks,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4624 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20111021/43ddd083/attachment.p7s>

Posted on the dev mailing list.