[Gc] GC_allochblk_nth bug

Romano Tenca rotenca at gmail.com
Sun Mar 2 17:19:45 PST 2008


I have a segmentation fault if i add these lines to gctest soon after
GC_INIT()

     GC_expand_hp(1024*1024*5);
     void *r = GC_MALLOC(2147483647-1024);

I am not sure, but the problem should be in GC_allochblk_nth() at these
lines:

     signed_word size_needed;    /* number of bytes in requested objects */
     signed_word size_avail;    /* bytes available in this block    */

     size_needed = HBLKSIZE * OBJ_SZ_TO_BLOCKS(sz);

With very high value for sz, size_needed should become a negative value
with the macro:

# define OBJ_SZ_TO_BLOCKS(sz) divHBLKSZ(sz + HBLKSIZE-1)

On my 32 bit system with large GC config, HBLKSIZE is 4096 and the sz
limit is:

LONG_MAX - 4094

The strange thing is that the segmentation does not appear without
calling GC_expand_hp().

I use THREADS and MUNMAP

Romano Paolo Tenca









More information about the Gc mailing list