[Gc] DONT_ADD_BYTE_AT_END and GC_malloc(0) (gc-7.1)

Shiro Kawai shiro at lava.net
Mon May 12 06:58:20 PDT 2008


Thanks Hans, but I had a problem with the patch against gc-7.1 tree.

From: Hans Boehm <Hans.Boehm at hp.com>
Subject: Re: [Gc] DONT_ADD_BYTE_AT_END and GC_malloc(0) (gc-7.1)
Date: Sun, 11 May 2008 22:13:53 -0700 (PDT)

> @@ -291,7 +291,7 @@
>       ptr_t q;
>       int j;
> 
> -    for (j = 1; j < TINY_FREELISTS; ++j) {
> +    for (j = 0; j < TINY_FREELISTS; ++j) {
>         q = p -> ptrfree_freelists[j];
>         if ((word)q > HBLKSIZE) GC_set_fl_marks(q);
>         q = p -> normal_freelists[j];

This caused SEGV for all gc tests.  It seems that gcj_freelists[0]
shouldn't be marked.  The following, as well as the above patch,
seems to fix the problem.

@@ -297,8 +297,10 @@
       q = p -> normal_freelists[j];
       if ((word)q > HBLKSIZE) GC_set_fl_marks(q);
 #     ifdef GC_GCJ_SUPPORT
+      if (j > 0) {
         q = p -> gcj_freelists[j];
         if ((word)q > HBLKSIZE) GC_set_fl_marks(q);
+      }
 #     endif /* GC_GCJ_SUPPORT */
     }
 }

> @@ -87,7 +87,7 @@
>       if (0 != GC_setspecific(GC_thread_key, p)) {
>   	ABORT("Failed to set thread specific allocation pointers");
>       }
> -    for (i = 1; i < TINY_FREELISTS; ++i) {
> +    for (i = 0; i < TINY_FREELISTS; ++i) {
>   	p -> ptrfree_freelists[i] = (void *)1;
>   	p -> normal_freelists[i] = (void *)1;
>   #	ifdef GC_GCJ_SUPPORT

OTOH, this doesn't seem necessary, for the size 0 freelists
are handled just below this for-loop.


More information about the Gc mailing list