From: Ivan Maidanski Date: Fri, 9 Dec 2016 23:07:25 +0000 (+0300) Subject: Workaround 'index out of bounds' UBSan false warning in push_marked X-Git-Tag: v7.6.2~271 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=14669e1a4520f42369badf2871c415f38e302431;p=gc Workaround 'index out of bounds' UBSan false warning in push_marked * 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. --- diff --git a/mark.c b/mark.c index 1b4224ce..c60b0107 100644 --- 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)