summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2021-05-10 16:16:50 -0500
committerDamien George <damien@micropython.org>2021-05-30 11:50:51 +1000
commit9a74546f8d2783502159cd99217c7d7e5d514261 (patch)
treeba52e456ce4232b61862cad241b49dfe3af96beb /py
parentf2dbc9102251f092e93b7c87cd8ffa5e9e5b880b (diff)
py/gc: Access the list of root pointers in an asan-compatible way.
Signed-off-by: Jeff Epler <jepler@gmail.com>
Diffstat (limited to 'py')
-rw-r--r--py/gc.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/py/gc.c b/py/gc.c
index 88adf2045..56111bd3b 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -342,9 +342,19 @@ void gc_collect_start(void) {
#endif
}
+// Address sanitizer needs to know that the access to ptrs[i] must always be
+// considered OK, even if it's a load from an address that would normally be
+// prohibited (due to being undefined, in a red zone, etc).
+#ifdef __GNUC__
+__attribute__((no_sanitize_address))
+#endif
+static void *gc_get_ptr(void **ptrs, int i) {
+ return ptrs[i];
+}
+
void gc_collect_root(void **ptrs, size_t len) {
for (size_t i = 0; i < len; i++) {
- void *ptr = ptrs[i];
+ void *ptr = gc_get_ptr(ptrs, i);
if (VERIFY_PTR(ptr)) {
size_t block = BLOCK_FROM_PTR(ptr);
if (ATB_GET_KIND(block) == AT_HEAD) {