[Gc] Exciting recursive invocation of GC_invoke_finalizers()...

Bruce Hoult bruce at hoult.org
Thu Jun 18 17:32:48 PDT 2009

On Fri, Jun 19, 2009 at 7:15 AM, Talbot, George<Gtalbot at locuspharma.com> wrote:
> Attached is a nice zip file of a 264K text file showing a backtrace from my program.  I've managed to find that one can cause an exciting crash if one allocates memory from a finalization function invoked by the collector.

There are many things you are not allowed to do in finalizer if you
have GC (any GC) set up to call finalizers synchronously from within a
GC (which means from within some random memory allocation attempt in
the calling program):

In particular you may not:

- allocate memory
- do anything that takes a lock

If you think you need to do that kind of thing then you should
configure the GC to not run finalizers synchronously, but instead
simply signal a thread (probably a dedicated one) that holds no locks
and is there purely to drain the finalizer queue.

The GC has support for querying whether there are finalizers waiting
to be run, and to explicitly run such finalizers.

More information about the Gc mailing list