[Gc] In bdwgc,
do finalizers need to be strictly async-signal safe?
Jean-Claude Beaudoin
jean.claude.beaudoin at gmail.com
Mon Jan 2 17:36:06 PST 2012
On Sat, Dec 31, 2011 at 1:02 AM, Boehm, Hans <hans.boehm at hp.com> wrote:
> They don't need to be fully async-signal-safe. The details depend on how
> finalizers are invoked. If GC_finalize_on_demand is not set (the default,
> but not recommended for anything but very simple uses) finalizers will be
> invoked on the way out of an allocation call. The finalizer must thus be
> callable in any context in which GC_malloc etc. can be called.
>
Boy, was I way off in the left field on this one! Somehow I was under the
wrong impression that
finalizers were called during the dynamic extent of the "stop-the-world"
signal handlers the GC
uses. But this is clearly not the case, thank you for setting me straight.
Your clarification has also been critical in finally nailing down a severe
bug in the system
I am currently working on.
>
> If GC_finalize_on_demand is set, and GC_invoke_finalizers is explicitly
> called, then finalizers are invoked only from GC_invoke_finalizers.
> Typically this will be done from a thread dedicated to that purpose. In
> that case it's fine to acquire locks, etc., from finalizers.
>
>
GC_finalize_on_demand is currently ignored in the code but I see the
superior value of
your recommended alternative and I will work to use it soon. Again, thank
you very much.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://napali.hpl.hp.com/pipermail/gc/attachments/20120102/cc790b9e/attachment.htm
More information about the Gc
mailing list