diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2018-07-11 23:09:00 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2018-07-11 23:09:00 +0300 |
commit | 77f4ff04d4408af0dcc0b55be184b61ea9daae72 (patch) | |
tree | ccb33126070dc02e133e3e3756b09f4de79dd53d /ptr_chck.c | |
parent | 6a7af12cbd3d2c27a208cff577662fca7e729a93 (diff) | |
download | bdwgc-77f4ff04d4408af0dcc0b55be184b61ea9daae72.tar.gz |
Fix GC_is_valid_displacement and GC_is_visible for non-small objects
* ptr_chck.c (GC_is_valid_displacement): Remove redundant
IS_FORWARDING_ADDR_OR_NIL(hhdr) call if GC_all_interior_pointers.
* ptr_chck.c (GC_is_valid_displacement): Do not goto fail if
p+sz-offset > h+1 but IS_FORWARDING_ADDR_OR_NIL(HDR(h+1)).
* ptr_chck.c (GC_is_visible): Transform comment about GC_base to
a TODO item; set hhdr to HDR(base) instead of HDR(p)
if HBLKPTR(base)!=HBLKPTR(p).
Diffstat (limited to 'ptr_chck.c')
-rw-r--r-- | ptr_chck.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -131,8 +131,7 @@ GC_API void * GC_CALL GC_is_valid_displacement(void *p) h = FORWARDED_ADDR(h, hhdr); hhdr = HDR(h); } - } - if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) { + } else if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) { goto fail; } sz = hhdr -> hb_sz; @@ -140,7 +139,8 @@ GC_API void * GC_CALL GC_is_valid_displacement(void *p) offset = pdispl % sz; if ((sz > MAXOBJBYTES && (word)p >= (word)h + sz) || !GC_valid_offsets[offset] - || (word)p - offset + sz > (word)(h + 1)) { + || ((word)p + (sz - offset) > (word)(h + 1) + && !IS_FORWARDING_ADDR_OR_NIL(HDR(h + 1)))) { goto fail; } return(p); @@ -215,10 +215,12 @@ GC_API void * GC_CALL GC_is_visible(void *p) } else { /* p points to the heap. */ word descr; - ptr_t base = (ptr_t)GC_base(p); /* Should be manually inlined? */ + ptr_t base = (ptr_t)GC_base(p); + /* TODO: should GC_base be manually inlined? */ - if (base == 0) goto fail; - if (HBLKPTR(base) != HBLKPTR(p)) hhdr = HDR((word)p); + if (NULL == base) goto fail; + if (HBLKPTR(base) != HBLKPTR(p)) + hhdr = HDR(base); descr = hhdr -> hb_descr; retry: switch(descr & GC_DS_TAGS) { |