]> granicus.if.org Git - gc/commitdiff
Workaround 'index out of bounds' UBSan false warning in push_marked
authorIvan Maidanski <ivmai@mail.ru>
Fri, 9 Dec 2016 23:07:25 +0000 (02:07 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 6 Feb 2017 17:24:27 +0000 (20:24 +0300)
* mark.c (GC_push_marked): Cast (h+1)->hb_body to word before
subtraction of sz value (and cast the result back to ptr_t).
* mark.c [ENABLE_DISCLAIM] (GC_push_unconditionally): Likewise.

mark.c

diff --git a/mark.c b/mark.c
index 1b4224cecd5c1b54405177901f68f2992319f1dd..c60b0107d8e3a1a4f5fd4fedda2b341880b95056 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -1784,7 +1784,7 @@ STATIC void GC_push_marked(struct hblk *h, hdr *hhdr)
     if (sz > MAXOBJBYTES) {
         lim = h -> hb_body;
     } else {
-        lim = (h + 1)->hb_body - sz;
+        lim = (ptr_t)((word)(h + 1)->hb_body - sz);
     }
 
     switch(BYTES_TO_GRANULES(sz)) {
@@ -1843,7 +1843,7 @@ STATIC void GC_push_marked(struct hblk *h, hdr *hhdr)
     if (sz > MAXOBJBYTES)
         lim = h -> hb_body;
     else
-        lim = (h + 1)->hb_body - sz;
+        lim = (ptr_t)((word)(h + 1)->hb_body - sz);
 
     GC_mark_stack_top_reg = GC_mark_stack_top;
     for (p = h -> hb_body; (word)p <= (word)lim; p += sz)