[Gc] Bug in GC_malloc_explicitly_typed_ignore_off_page()

Reimer Behrends behrends at gmail.com
Mon Dec 3 10:26:12 PST 2012


Hi folks,

it appears as though GC_malloc_explicitly_typed_ignore_off_page() has a 
typo. Namely, it uses BYTES_TO_WORDS() instead of BYTES_TO_GRANULES() in 
the else branch. When the result is then used with GRANULES_TO_WORDS() 
to calculate an offset, that offset is incorrect.

I've attached a patch against 7.2d.

On a related note, is it intended that 
GC_generic_malloc_ignore_off_page() is marked as GC_INNER instead of 
GC_API and does not have a prototype in gc_mark.h?

			Reimer Behrends
-------------- next part --------------
*** gc-7.2d/typd_mlc.c	2012-08-09 21:25:13.000000000 +0100
--- gc-7.2d/typd_mlc.c	2012-12-03 17:00:42.000000000 +0000
***************
*** 642,648 ****
     } else {
         op = (ptr_t)GENERAL_MALLOC_IOP(lb, GC_explicit_kind);
         if (op != NULL) {
!          lg = BYTES_TO_WORDS(GC_size(op));
           ((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d;
         }
     }
--- 642,648 ----
     } else {
         op = (ptr_t)GENERAL_MALLOC_IOP(lb, GC_explicit_kind);
         if (op != NULL) {
!          lg = BYTES_TO_GRANULES(GC_size(op));
           ((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d;
         }
     }


More information about the Gc mailing list