Re: [Gc] Figured out my problem with finalization cycles. Useful patchattached.

Ivan Maidanski ivmai at mail.ru
Fri Jun 5 00:35:32 PDT 2009


Hi!

"Talbot, George" <Gtalbot at locuspharma.com> wrote:
> Hi all,
> ...
> To help debug this I made a small fix to GC_print_callers in os_dep.c.  GC_print_callers was taking the LOCK() so as to increment and decrement the reentry_count.  I changed reentry_count to AO_t and used the libatomicops operations to get rid of the lock.  I then added a #ifdef'd GC_print_backtrace() right after the warning in GC_finalize().  I also removed the UNLOCK() and LOCK() around GC_generate_random_backtrace() in GC_notify_or_invoke_finalizers() as it was no longer needed.
> 
> Attached is the patch, though it isn't yet perfect.

AO_fetch_and_add/sub1() are not always available, so guard them (falling back to locking) with AO_HAVE_fetch_and_add1.

> 
> Question:  How do I get GC_print_backtrace() to stop when it's printing a cycle?
> 
> I currently have to ctrl-C the program when it catches a finalization cycle when I have debug turned on.
> 
> One more question:  Is my sending of these patches useful to anyone?
Sure.

> Will they be applied, do you think?  Are they in the right format?

The format is right.

> 
> --
> George T. Talbot
> <gtalbot at locuspharma.com>

Bye.


More information about the Gc mailing list