Skip to content

Commit 9a74546

Browse files
jeplerdpgeorge
authored andcommitted
py/gc: Access the list of root pointers in an asan-compatible way.
Signed-off-by: Jeff Epler <[email protected]>
1 parent f2dbc91 commit 9a74546

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

py/gc.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,19 @@ void gc_collect_start(void) {
342342
#endif
343343
}
344344

345+
// Address sanitizer needs to know that the access to ptrs[i] must always be
346+
// considered OK, even if it's a load from an address that would normally be
347+
// prohibited (due to being undefined, in a red zone, etc).
348+
#ifdef __GNUC__
349+
__attribute__((no_sanitize_address))
350+
#endif
351+
static void *gc_get_ptr(void **ptrs, int i) {
352+
return ptrs[i];
353+
}
354+
345355
void gc_collect_root(void **ptrs, size_t len) {
346356
for (size_t i = 0; i < len; i++) {
347-
void *ptr = ptrs[i];
357+
void *ptr = gc_get_ptr(ptrs, i);
348358
if (VERIFY_PTR(ptr)) {
349359
size_t block = BLOCK_FROM_PTR(ptr);
350360
if (ATB_GET_KIND(block) == AT_HEAD) {

0 commit comments

Comments
 (0)