Skip to content

Commit 184f201

Browse files
committed
gc.c: Access the list of root pointers asan-compatibly.
Signed-off-by: Jeff Epler <[email protected]>
1 parent 0e87459 commit 184f201

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

py/gc.c

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

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

0 commit comments

Comments
 (0)