mirror of
https://github.com/licsber/micropython.git
synced 2024-09-20 09:00:23 +08:00
py/gc: Access the list of root pointers in an asan-compatible way.
Signed-off-by: Jeff Epler <jepler@gmail.com>
This commit is contained in:
parent
f2dbc91022
commit
9a74546f8d
12
py/gc.c
12
py/gc.c
@ -342,9 +342,19 @@ void gc_collect_start(void) {
|
|||||||
#endif
|
#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) {
|
void gc_collect_root(void **ptrs, size_t len) {
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
void *ptr = ptrs[i];
|
void *ptr = gc_get_ptr(ptrs, i);
|
||||||
if (VERIFY_PTR(ptr)) {
|
if (VERIFY_PTR(ptr)) {
|
||||||
size_t block = BLOCK_FROM_PTR(ptr);
|
size_t block = BLOCK_FROM_PTR(ptr);
|
||||||
if (ATB_GET_KIND(block) == AT_HEAD) {
|
if (ATB_GET_KIND(block) == AT_HEAD) {
|
||||||
|
Loading…
Reference in New Issue
Block a user