diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2021-12-02 07:52:18 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2021-12-02 11:03:13 +0300 |
commit | 8c5cc147c893f42d531707afb1aa838c11459445 (patch) | |
tree | 71a31452e694a9b679c0f0aa300c9520500ba8b7 | |
parent | db9f5a329de776992ce8cc6f9e580911cdb15f30 (diff) | |
download | bdwgc-8c5cc147c893f42d531707afb1aa838c11459445.tar.gz |
Do not call SET_HDR() to remove forwarding counts if none exists in hblk
Issue #237 (bdwgc).
This also prevents writing zeros to GC_all_nils by GC_remove_counts().
* headers.c (GC_remove_counts): If HDR(h+1) is zero (and sz is at least
one block) then assert that HDR() of other hbp elements is zero too and
then return (w/o SET_HDR(hbp,0) invocation).
* ptr_chck.c (GC_is_valid_displacement): Remove comment that if(p) is
needed to avoid a data race.
-rw-r--r-- | headers.c | 9 | ||||
-rw-r--r-- | ptr_chck.c | 4 |
2 files changed, 9 insertions, 4 deletions
@@ -310,6 +310,15 @@ GC_INNER void GC_remove_counts(struct hblk *h, size_t sz/* bytes */) { struct hblk * hbp; + if (sz <= HBLKSIZE) return; + if (HDR(h+1) == 0) { +# ifdef GC_ASSERTIONS + for (hbp = h+2; (word)hbp < (word)h + sz; hbp++) + GC_ASSERT(HDR(hbp) == 0); +# endif + return; + } + for (hbp = h+1; (word)hbp < (word)h + sz; hbp += 1) { SET_HDR(hbp, 0); } @@ -123,11 +123,7 @@ GC_API void * GC_CALL GC_is_valid_displacement(void *p) word sz; if (!EXPECT(GC_is_initialized, TRUE)) GC_init(); - - /* A quick check to avoid TSan report about the data race */ - /* between GC_find_header() and GC_remove_counts(). */ if (NULL == p) return NULL; - hhdr = HDR((word)p); if (hhdr == 0) return(p); h = HBLKPTR(p); |