[Gc] GC_DARWIN_THREADS in gc_config_macros.h

Boehm, Hans hans.boehm at hp.com
Thu May 10 17:02:17 PDT 2007


[Another belated reply ...]

> -----Original Message-----
> From: gc-bounces at napali.hpl.hp.com 
> [mailto:gc-bounces at napali.hpl.hp.com] On Behalf Of S M Ryan
> Sent: Monday, April 16, 2007 8:38 AM
> To: Boehm-gc
> Subject: Re: [Gc] GC_DARWIN_THREADS in gc_config_macros.h
> 
> I don't know if this is official, but to get it to work with 
> forks and threads, I needed to force GC_HANDLE_FORKS and include it as
> 	#define GC_PTHREADS
> 	#include "gc.h"
> and then
> 	#include <pthread.h>
> as documented.

I believe that should only be necessary if you call GC_malloc() or
friends between a fork() and exec() in a multithreaded client.  If you
follow Posix rules for plain malloc(), that isn't allowed, since only
async-signal-safe calls can appear there.  I point this out since few
people seem to realize this, and even if you define GC_HANDLE_FORKS, you
may have other calls there that can cause problems.

Hans



More information about the Gc mailing list