Add a missing asan_unpoisoning_p in gc_set_candidate_object_i

It walks the heap, and checks for T_NONE and T_ZOMBIE objects, so it
needs to unpoison these slots before accessing them when ASAN is
enabled.
This commit is contained in:
KJ Tsanaktsidis 2024-03-12 18:24:07 +11:00
parent 75234beb24
commit dc9d2455b6

26
gc.c
View File

@ -9362,18 +9362,20 @@ gc_set_candidate_object_i(void *vstart, void *vend, size_t stride, void *data)
rb_objspace_t *objspace = &rb_objspace;
VALUE v = (VALUE)vstart;
for (; v != (VALUE)vend; v += stride) {
switch (BUILTIN_TYPE(v)) {
case T_NONE:
case T_ZOMBIE:
break;
case T_STRING:
// precompute the string coderange. This both save time for when it will be
// eventually needed, and avoid mutating heap pages after a potential fork.
rb_enc_str_coderange(v);
// fall through
default:
if (!RVALUE_OLD_P(v) && !RVALUE_WB_UNPROTECTED(v)) {
RVALUE_AGE_SET_CANDIDATE(objspace, v);
asan_unpoisoning_object(v) {
switch (BUILTIN_TYPE(v)) {
case T_NONE:
case T_ZOMBIE:
break;
case T_STRING:
// precompute the string coderange. This both save time for when it will be
// eventually needed, and avoid mutating heap pages after a potential fork.
rb_enc_str_coderange(v);
// fall through
default:
if (!RVALUE_OLD_P(v) && !RVALUE_WB_UNPROTECTED(v)) {
RVALUE_AGE_SET_CANDIDATE(objspace, v);
}
}
}
}