From: hboehm Date: Thu, 11 Sep 2008 01:37:57 +0000 (+0000) Subject: 2008-09-10 Hans Boehm X-Git-Tag: gc7_2alpha2~64 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9567fad48b54e60255aa52f60bc43af95da77b33;p=gc 2008-09-10 Hans Boehm * dbg_mlc.c (GC_print_smashed_obj): Increase robustness with smashed string, (GC_debug_free_inner): Mark as free. * mallocx.c (GC_malloc_many): Always clear new block if GC_debugging_started. * reclaim.c: Move GC_debugging_started from GC_reclaim_small_nonempty_block() to GC_reclaim_generic(), which is also called directly. * doc/README: Fix spelling error. Update license summary. * include/gc.h (GC_PRE_INCR3, GC_POST_INCR3): add (void **) casts. * tests/test.c: Don't define GC_DEBUG if already defined. --- diff --git a/ChangeLog b/ChangeLog index b3b43cc4..bffe951e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-09-10 Hans Boehm + * dbg_mlc.c (GC_print_smashed_obj): Increase robustness with + smashed string, (GC_debug_free_inner): Mark as free. + * mallocx.c (GC_malloc_many): Always clear new block if + GC_debugging_started. + * reclaim.c: Move GC_debugging_started from + GC_reclaim_small_nonempty_block() to GC_reclaim_generic(), + which is also called directly. + * doc/README: Fix spelling error. Update license summary. + * include/gc.h (GC_PRE_INCR3, GC_POST_INCR3): add (void **) casts. + * tests/test.c: Don't define GC_DEBUG if already defined. + 2008-08-27 Hans Boehm * doc/simple_example.html: update --enable-full-debug reference, Make HTML formatting standards compliant. diff --git a/dbg_mlc.c b/dbg_mlc.c index 7b23b525..a09bd54f 100644 --- a/dbg_mlc.c +++ b/dbg_mlc.c @@ -420,7 +420,9 @@ STATIC void GC_print_smashed_obj(ptr_t p, ptr_t clobbered_addr) GC_err_printf(", appr. sz = %ld)\n", (GC_size((ptr_t)ohdr) - DEBUG_BYTES)); } else { - if (ohdr -> oh_string[0] == '\0') { + if ((word)(ohdr -> oh_string) < HBLKSIZE) { + GC_err_puts("(smashed string)"); + } else if (ohdr -> oh_string[0] == '\0') { GC_err_puts("EMPTY(smashed?)"); } else { GC_err_puts(ohdr -> oh_string); @@ -758,7 +760,11 @@ extern void GC_free_inner(void * p); /* Used internally; we assume it's called correctly. */ void GC_debug_free_inner(void * p) { - GC_free_inner(GC_base(p)); + ptr_t base = GC_base(p); + GC_ASSERT((ptr_t)p - (ptr_t)base == sizeof(oh)); + /* Invalidate size */ + ((oh *)base) -> oh_sz = GC_size(base); + GC_free_inner(base); } #endif diff --git a/doc/README b/doc/README index 69e4389f..b7bbfe6f 100644 --- a/doc/README +++ b/doc/README @@ -28,9 +28,14 @@ modified is included with the above copyright notice. A few of the files needed to use the GNU-style build procedure come with slightly different licenses, though they are all similar in spirit. A few are GPL'ed, but with an exception that should cover all uses in the -collector. (If you are concerned about such things, I recommend you look +collector. (If you are concerned about such things, I recommend you look at the notice in config.guess or ltmain.sh.) +The atomic_ops library contains some code that is covered by the GNU General +Public License, but is not needed by, nor linked into the collector library. +It is included here only becuase the atomic_ops distribution is, for +simplicity, included in its entirety. + This is version 7.2alpha1 of a conservative garbage collector for C and C++. You might find a more recent version of this at diff --git a/include/gc.h b/include/gc.h index fcb0f3c5..1543796a 100644 --- a/include/gc.h +++ b/include/gc.h @@ -964,9 +964,9 @@ GC_API void GC_dump(void); # define GC_PTR_ADD3(x, n, type_of_result) \ ((type_of_result)GC_same_obj((x)+(n), (x))) # define GC_PRE_INCR3(x, n, type_of_result) \ - ((type_of_result)GC_pre_incr(&(x), (n)*sizeof(*x))) + ((type_of_result)GC_pre_incr((void **)(&(x)), (n)*sizeof(*x))) # define GC_POST_INCR3(x, n, type_of_result) \ - ((type_of_result)GC_post_incr(&(x), (n)*sizeof(*x))) + ((type_of_result)GC_post_incr((void **)(&(x)), (n)*sizeof(*x))) # define GC_PTR_ADD(x, n) \ GC_PTR_ADD3(x, n, typeof(x)) # define GC_PRE_INCR(x, n) \ diff --git a/mallocx.c b/mallocx.c index 913192fd..71fb19a9 100644 --- a/mallocx.c +++ b/mallocx.c @@ -393,7 +393,7 @@ DCL_LOCK_STATE; GC_release_mark_lock(); # endif - op = GC_build_fl(h, lw, ok -> ok_init, 0); + op = GC_build_fl(h, lw, (ok -> ok_init || GC_debugging_started), 0); # ifdef PARALLEL_MARK *result = op; GC_acquire_mark_lock(); diff --git a/reclaim.c b/reclaim.c index 0b01b1a0..13db28d8 100644 --- a/reclaim.c +++ b/reclaim.c @@ -216,7 +216,7 @@ ptr_t GC_reclaim_generic(struct hblk * hbp, hdr *hhdr, size_t sz, GC_ASSERT(GC_find_header((ptr_t)hbp) == hhdr); GC_remove_protection(hbp, 1, (hhdr)->hb_descr == 0 /* Pointer-free? */); - if (init) { + if (init || GC_debugging_started) { result = GC_reclaim_clear(hbp, hhdr, sz, list, count); } else { GC_ASSERT((hhdr)->hb_descr == 0 /* Pointer-free block */); @@ -247,7 +247,7 @@ STATIC void GC_reclaim_small_nonempty_block(struct hblk *hbp, GC_reclaim_check(hbp, hhdr, sz); } else { *flh = GC_reclaim_generic(hbp, hhdr, sz, - (ok -> ok_init || GC_debugging_started), + ok -> ok_init, *flh, &GC_bytes_found); } } diff --git a/tests/test.c b/tests/test.c index f33c9a72..7379f36f 100644 --- a/tests/test.c +++ b/tests/test.c @@ -20,7 +20,7 @@ # undef GC_BUILD -#if defined(DBG_HDRS_ALL) || defined(MAKE_BACK_GRAPH) +#if (defined(DBG_HDRS_ALL) || defined(MAKE_BACK_GRAPH)) && !defined(GC_DEBUG) # define GC_DEBUG #endif