Re: [Gc] Exciting recursive invocation of GC_invoke_finalizers()...
ivmai at mail.ru
Thu Jun 18 23:38:39 PDT 2009
Bruce Hoult <bruce at hoult.org> wrote:
> 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
Wrong assumptions (both). You are allowed to do it even from a finalizer notifier.
> 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.
This is not always possible, e.g if single-threaded.
> 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