bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Gc] pthreads and libgc


From: Boehm, Hans
Subject: RE: [Gc] pthreads and libgc
Date: Sun, 20 Mar 2011 03:51:05 +0000

> From: Andy Wingo
> ...
> [From Ivan:]
> > But, anyway, it is recommended to initialize GC explicitly (i.e. by
> > GC_INIT), so placing GC_INIT() (together with
> > GC_set_all_interior_pointer) to the beginning of your main() should
> be
> > the best way out.
> 
> We can add some documentation to this regard in the manual, if needed.
> But is there no way to get around this, and do the right thing?  For
> example, to avoid implicit GC initialization in response to a
> pthread_create.
> 
The problem is that GC_pthread_create needs to allocate memory, and relies on 
some other GC state.  Hence the GC must have been initialized for it to work.

For newer collectors, it might be possible to instead arrange for 
pthread_create not to be redirected to GC_pthread_create, and for threads that 
need to be known to the GC to register themselves.  I haven't thought through 
whether that might be feasible here.

Another imperfect solution might be to set all_interior_pointers and probably 
call GC_INIT in a constructor, either a C++ constructor, or a C function that's 
suitably attributed.  That still fails if other constructors run into this 
problem before our constructor runs.

Hans



reply via email to

[Prev in Thread] Current Thread [Next in Thread]