From: Leandro Lucarella Date: Mon, 2 Aug 2010 00:59:26 +0000 (-0300) Subject: Return the real size that can be used in getInfo() X-Git-Url: https://git.llucax.com/software/dgc/cdgc.git/commitdiff_plain/876c4089652c85740c66a62899a1e32837e15ad5 Return the real size that can be used in getInfo() getInfo() was not aware of the sentinel, returning a size larger than the size usable by the user. There are probably more places where this happens. --- diff --git a/rt/gc/cdgc/gc.d b/rt/gc/cdgc/gc.d index 267b42f..f2d2f6e 100644 --- a/rt/gc/cdgc/gc.d +++ b/rt/gc/cdgc/gc.d @@ -302,8 +302,20 @@ BlkInfo getInfo(void* p) info.base = pool.findBase(p); info.size = pool.findSize(info.base); info.attr = getAttr(pool, cast(size_t)(info.base - pool.baseAddr) / 16u); - if (!opts.options.conservative && !(info.attr & BlkAttr.NO_SCAN)) + if (has_pointermap(info.attr)) { info.size -= size_t.sizeof; // PointerMap bitmask + // Points to the PointerMap bitmask pointer, not user data + if (p >= (info.base + info.size)) { + return BlkInfo.init; + } + } + if (opts.options.sentinel) { + info.base = sentinel_add(info.base); + // points to sentinel data, not user data + if (p < info.base || p >= sentinel_post(info.base)) + return BlkInfo.init; + info.size -= SENTINEL_EXTRA; + } return info; }