From d9119e384e5ddcd6ee187229a30a0aef2c5203ab Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sat, 10 Dec 2016 02:07:25 +0300 Subject: [PATCH] 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. --- mark.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mark.c b/mark.c index 31566666..b5548478 100644 --- a/mark.c +++ b/mark.c @@ -1774,7 +1774,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)) { @@ -1833,7 +1833,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) -- 2.40.0