boehm-gc: finalization doesn't work with --enable-gc-debug

Boehm, Hans hans.boehm@hp.com
Tue Jun 21 18:56:00 GMT 2005


Andrew -

As always, the theory is that this can't possibly be happening :-)

The idea is that all the registration calls should be using the
upper case GC_REGISTER_FINALIZER... calls.  These are macro defined to
GC_debug_register_finalizer... .  This routine adjusts the pointer
you pass it to point to the object base.  And it wraps the finalization
function with a shim that adjusts the pointer back, to make all of
this transparent to the client.

Possible failure causes include:

- A direct call to the lower case version of the routines somewhere
in libgcj, though I couldn't quickly find one.
- Incomplete recompilation when you turn on GC debugging.
- Some piece of this is getting built in debug mode without GC_DEBUG
defined.

I hope this helps.

Hans

> -----Original Message-----
> From: java-patches-owner@gcc.gnu.org 
> [mailto:java-patches-owner@gcc.gnu.org] On Behalf Of Andrew Haley
> Sent: Tuesday, June 21, 2005 7:11 AM
> To: java-patches@gcc.gnu.org
> Subject: boehm-gc: finalization doesn't work with --enable-gc-debug
> 
> 
> With gc debugging enabled, a Java reference doesn't point to 
> the start of a gc object but to somewhere in the middle of 
> the object.  As a result of this, objects are prematurely finalized.
> 
> I expect that this same problem occurs in other places too, 
> but I'm waiting for feedback as to whether this is the right approach.
> 
> Andrew.
> 
> 
> 2005-06-21  Andrew Haley  <aph@redhat.com>
> 
> 	* finalize.c (GC_finalize): Use GC_base of a pointer: if gc
> 	debugging is enabled, pointers don't point to the start of
> 	objects.
> 
> Index: finalize.c 
> ===================================================================
> RCS file: /cvs/gcc/gcc/boehm-gc/finalize.c,v
> retrieving revision 1.14
> diff -u -p -r1.14 finalize.c
> --- finalize.c	28 Aug 2004 00:41:40 -0000	1.14
> +++ finalize.c	21 Jun 2005 13:43:35 -0000
> @@ -557,7 +557,7 @@ void GC_finalize()
>        while (curr_dl != 0) {
>          real_ptr = (ptr_t)REVEAL_POINTER(curr_dl -> dl_hidden_obj);
>          real_link = (ptr_t)REVEAL_POINTER(curr_dl -> dl_hidden_link);
> -        if (!GC_is_marked(real_ptr)) {
> +        if (!GC_is_marked(GC_base(real_ptr))) {
>              *(word *)real_link = 0;
>              next_dl = dl_next(curr_dl);
>              if (prev_dl == 0) {
> 



More information about the Java-patches mailing list