[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master a2323c7 2/3: Suppress sanitizer errors about pointer arithmetic i
From: |
Philipp Stephani |
Subject: |
master a2323c7 2/3: Suppress sanitizer errors about pointer arithmetic in a few places |
Date: |
Sat, 1 Aug 2020 11:14:44 -0400 (EDT) |
branch: master
commit a2323c7ccb0eab1b6395d5d1d7e18db617354e13
Author: Philipp Stephani <phst@google.com>
Commit: Philipp Stephani <phst@google.com>
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 76bb208..5b9c6e4 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);