Re[2]: [Gc] I_DONT_HOLD_LOCK removal in GC_print_obj and friends

Ivan Maidanski ivmai at mail.ru
Tue Nov 25 02:29:08 PST 2008


Hi!

"Boehm, Hans" <hans.boehm at hp.com> wrote:
> This doesn't look correct to me, since GC_print_callers acquires tha allocator lock, and on some platforms does all sorts of nasty stuff that might result in allocation with REDIRECT_MALLOC.  Is there a way to avoid acquiring the lock for this call?  I haven't had a chance to look in detail.
> 
> Hans

Here is the solution (at least, temporal). I think You don't like it neither but it's working (other calls to GC_print_heap_obj are safe).

> 
> > -----Original Message-----
> > From: gc-bounces at napali.hpl.hp.com
> > [mailto:gc-bounces at napali.hpl.hp.com] On Behalf Of Ivan Maidanski
> > Sent: Monday, October 27, 2008 8:49 AM
> > To: gc at napali.hpl.hp.com
> > Subject: [Gc] I_DONT_HOLD_LOCK removal in GC_print_obj and friends
> >
> > Hi!
> >
> > I_DONT_HOLD_LOCK() assertion is violated in
> > GC_debug_print_heap_obj_proc() (called indirectly from
> > GC_maybe_gc()) when test.c and gclib are compiled for Win32
> > with -DALL_INTERIOR_POINTERS -DGC_THREADS -DGC_ASSERTIONS
> > -DPRINT_BLACK_LIST -DDBG_HDRS_ALL.
> >
> > This assertion can't be replaced wih I_HOLD_LOCK() because it
> > is violated too (called indirectly from GC_help_marker())
> > when test.c and gclib are compiled for Win32 with
> > -DALL_INTERIOR_POINTERS -DGC_THREADS -DGC_ASSERTIONS
> > -DPRINT_BLACK_LIST -DDBG_HDRS_ALL -DPARALLEL_MARK
> > -DAO_ASSUME_WINDOWS98.
> >
> > I don't know the purpose of this assertion.
> > Since it works ok without this assertion (and in
> > GC_print_obj(), and GC_print_smashed_obj()), the attached
> > patch removes these assertions.
> >
> > PS. The same assertion in GC_print_all_smashed_() is ok.
> >
> > Bye.
> >
> >
> 

Bye.

-------------- next part --------------
diff -ru bdwgc/blacklst.c updated/bdwgc/blacklst.c
--- bdwgc/blacklst.c	2008-07-26 04:51:33.000000000 +0400
+++ updated/bdwgc/blacklst.c	2008-11-25 13:18:36.000000000 +0300
@@ -74,7 +74,10 @@
 	}
     } else {
 	GC_err_printf("in object at ");
-	(*GC_print_heap_obj)(base);
+	/* FIXME: We can't call the debug version of GC_print_heap_obj	*/
+	/* (with PRINT_CALL_CHAIN) here because	the lock is held and	*/
+	/* the world is stopped.					*/
+	GC_default_print_heap_obj_proc(base);
     }
 }
 #endif
diff -ru bdwgc/dbg_mlc.c updated/bdwgc/dbg_mlc.c
--- bdwgc/dbg_mlc.c	2008-11-20 12:05:32.000000000 +0300
+++ updated/bdwgc/dbg_mlc.c	2008-11-25 12:15:44.000000000 +0300
@@ -376,6 +376,7 @@
 {
     register oh * ohdr = (oh *)GC_base(p);
     
+    GC_ASSERT(I_DONT_HOLD_LOCK());
     GC_err_printf("%p (", ((ptr_t)ohdr + sizeof(oh)));
     GC_err_puts(ohdr -> oh_string);
 #   ifdef SHORT_DBG_HDRS
@@ -391,6 +392,7 @@
 
 STATIC void GC_debug_print_heap_obj_proc(ptr_t p)
 {
+    GC_ASSERT(I_DONT_HOLD_LOCK());
     if (GC_HAS_DEBUG_INFO(p)) {
 	GC_print_obj(p);
     } else {
@@ -406,6 +408,7 @@
 {
     register oh * ohdr = (oh *)GC_base(p);
     
+    GC_ASSERT(I_DONT_HOLD_LOCK());
     if (clobbered_addr <= (ptr_t)(&(ohdr -> oh_sz))
         || ohdr -> oh_string == 0) {
 	GC_err_printf(


More information about the Gc mailing list