From a2323c7ccb0eab1b6395d5d1d7e18db617354e13 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Sat, 1 Aug 2020 16:58:06 +0200 Subject: [PATCH] Suppress sanitizer errors about pointer arithmetic in a few places We perform weird pointer arithmetic due to the layout of Lisp_Objects holding symbols. ASan/UBSan warns about that (Bug#42530). Suppress the warnings by performing the arithmetic on integer types and casting back to pointers. * src/alloc.c (mark_maybe_object, mark_memory): Temporarily cast pointer to 'intptr_t'. --- src/alloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index 76bb20876b0..5b9c6e4eb1f 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -4638,7 +4638,8 @@ mark_maybe_object (Lisp_Object obj) break; } - void *po = (char *) XLP (obj) + (offset - LISP_WORD_TAG (type_tag)); + void *po = (char *) ((intptr_t) (char *) XLP (obj) + + (offset - LISP_WORD_TAG (type_tag))); /* If the pointer is in the dump image and the dump has a record of the object starting at the place where the pointer points, we @@ -4849,7 +4850,7 @@ mark_memory (void const *start, void const *end) On a host with 32-bit pointers and 64-bit Lisp_Objects, a Lisp_Object might be split into registers saved into non-adjacent words and P might be the low-order word's value. */ - p += (intptr_t) lispsym; + p = (char *) ((intptr_t) p + (intptr_t) lispsym); mark_maybe_pointer (p); verify (alignof (Lisp_Object) % GC_POINTER_ALIGNMENT == 0); -- 2.39.2