[Gc] infinite loop since 6.3alpha5

Hans Boehm Hans.Boehm at hp.com
Sat Jun 5 23:07:40 PDT 2004


Thanks.  GC_collect_at_heapsize is being set incorrectly, and may in
extreme cases like this be less than the actual heap size.  The
code to set it is erroneously using the old heap size instead of the
new one.

Here's a quick attempt at a patch, which I should probably have looked
at in the morning before sending:

Hans

--- alloc.c.orig        2004-06-05 22:53:14.000000000 -0700
+++ alloc.c     2004-06-05 22:58:07.000000000 -0700
@@ -942,12 +942,7 @@
             (GC_PTR)GC_min((ptr_t)GC_least_plausible_heap_addr,
                            (ptr_t)space - expansion_slop);
     }
-    /* Force GC before we are likely to allocate past expansion_slop */
-      GC_collect_at_heapsize =
-         GC_heapsize + expansion_slop - 2*MAXHINCR*HBLKSIZE;
 #   if defined(LARGE_CONFIG)
-      if (GC_collect_at_heapsize < GC_heapsize /* wrapped */)
-       GC_collect_at_heapsize = (word)(-1);
       if (((ptr_t)GC_greatest_plausible_heap_addr <= (ptr_t)space + bytes
            || (ptr_t)GC_least_plausible_heap_addr >= (ptr_t)space)
          && GC_heapsize > 0) {
@@ -958,6 +953,13 @@
     GC_prev_heap_addr = GC_last_heap_addr;
     GC_last_heap_addr = (ptr_t)space;
     GC_add_to_heap(space, bytes);
+    /* Force GC before we are likely to allocate past expansion_slop */
+      GC_collect_at_heapsize =
+         GC_heapsize + expansion_slop - 2*MAXHINCR*HBLKSIZE;
+#     if defined(LARGE_CONFIG)
+        if (GC_collect_at_heapsize < GC_heapsize /* wrapped */)
+         GC_collect_at_heapsize = (word)(-1);
+#     endif
     return(TRUE);
 }



On Sat, 5 Jun 2004, Paolo Molaro wrote:

> On 06/05/04 Paolo Molaro wrote:
> > It looks like gc 6.3alpha5 introduced a bug.
> > It was first found by running the mono testsuite, but a simple C program
> > gives the same results:
> >
> > #include <gc.h>
> >
> > int main ()
> > {
> >     void *p1 = GC_malloc (30000000 * 2);
> >     void *p2 = GC_malloc (6000014);
> > }
>
> This fixes it, though I guess it may have some performance
> implications.
>
> --- alloc.c.old	2004-06-05 19:33:50.000000000 +0200
> +++ alloc.c	2004-06-05 19:33:57.000000000 +0200
> @@ -235,8 +235,7 @@
>  /* Have we allocated enough to amortize a collection? */
>  GC_bool GC_should_collect()
>  {
> -    return(GC_adj_words_allocd() >= min_words_allocd()
> -	   || GC_heapsize >= GC_collect_at_heapsize);
> +    return(GC_adj_words_allocd() >= min_words_allocd());
>  }
>
> lupus
>
> --
> -----------------------------------------------------------------
> lupus at debian.org                                     debian/rules
> lupus at ximian.com                             Monkeys do it better
> _______________________________________________
> Gc mailing list
> Gc at linux.hpl.hp.com
> http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
>


More information about the Gc mailing list