[Gc] interior pointers to large allocations

Benjamin Smedberg benjamin at smedbergs.us
Tue Sep 16 13:54:03 PDT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear GC list:

I have a problem with interior pointers that doesn't seem to be covered by
the docs.

I have pre-existing code which allocates a structure

struct nsStringBuffer {
  bool mShared;
  size_t mLength;
  char mBuffer[1]; // arbitrary length
};

The code then stores a pointer to mBuffer, instead of a pointer to the root
allocation. I figured this would be ok, since interior pointers are being
scanned. But I was having heap corruption and starting sprinkling calls to
GC_is_valid_displacement into my code.

I found that if the allocated size is larger than a hblk,
GC_is_valid_displacement rejects all interior pointers, due to this line:
http://hg.mozilla.org/users/bsmedberg_mozilla.com/gcmonkey/file/96af1e84dbaa/memory/boehmgc/ptr_chck.c#l143

* Am I misusing GC_is_valid_displacement?
* Is this a bug in GC_is_valid_displacement
* or are interior pointers to large allocations actually not recognized?

- --BDS
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFI0BzrSSwGp5sTYNkRAlgYAJ0dwq7GFxxa2TeCug+V47QCnyvwiACgi4qS
gbI0OVXsp5776hsbIDYH8VM=
=UKCR
-----END PGP SIGNATURE-----


More information about the Gc mailing list