[Gc] RE: [bdwgc] memory fault with incremental collection (#25)

Boehm, Hans hans.boehm at hp.com
Thu Aug 22 12:17:01 PDT 2013


It sounds to me like you're getting EFAULT during a read() system call which is writing to the garbage-collected heap.  That's unfortunately an expected problem with incremental collection.  Incremental collection has to protect the heap and catch write faults to track stores into the heap.  That works find for store instructions, but doesn't work correctly for Linux system calls.

I suspect the easiest correct way out is to make sure that the read system call writes to an atomic (pointer-free) section of the heap, and call GC_incremental_protection_needs() to check whether it is safe to call GC_enable_incremental.  It should be on normal x86 systems.

As an alternative, it should be possible to wrap the read system call so as to avoid this problem.  Last I checked, there was sample code to do so in os_dep.c (grep for __wrap_read).

Hans



More information about the Gc mailing list