Skip to content

Commit 1ad94dd

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

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

py/gc.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,18 @@ 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+
__attribute__((no_sanitize_address))
350+
static void *gc_get_ptr(void **ptrs, int i) {
351+
return ptrs[i];
352+
}
353+
345354
void gc_collect_root(void **ptrs, size_t len) {
346355
for (size_t i = 0; i < len; i++) {
347-
void *ptr = ptrs[i];
356+
void *ptr = gc_get_ptr(ptrs, i);
348357
if (VERIFY_PTR(ptr)) {
349358
size_t block = BLOCK_FROM_PTR(ptr);
350359
if (ATB_GET_KIND(block) == AT_HEAD) {

0 commit comments

Comments
 (0)