summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2024-07-04 09:25:50 -0400
committerPeter Zhu <[email protected]>2024-07-04 09:25:50 -0400
commitc480dec1ccf34b8452438811c5ef0f76cbb2a063 (patch)
tree9660e7f1285a6c2b5904a39aac9b76b943c1ebd4
parent478ada0e2bb11c5aaac0f8d30cdef12a967c2c03 (diff)
Fix RUBY_FREE_AT_EXIT with ASAN
When Ruby is built with ASAN and RUBY_FREE_AT_EXIT is enabled, the following error occurs: READ of size 8 at 0x74c666610020 thread T0 #0 0x593b6712ecc6 in RB_BUILTIN_TYPE include/ruby/internal/value_type.h:191:30 #1 0x593b6712ecc6 in rb_gc_impl_shutdown_free_objects gc_impl.c:3208:17 #2 0x593b6749a62e in ruby_vm_destruct vm.c:3133:17
-rw-r--r--gc_impl.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/gc_impl.c b/gc_impl.c
index c019bb7569..84e0b5df8d 100644
--- a/gc_impl.c
+++ b/gc_impl.c
@@ -3205,8 +3205,10 @@ rb_gc_impl_shutdown_free_objects(void *objspace_ptr)
uintptr_t pend = p + page->total_slots * stride;
for (; p < pend; p += stride) {
VALUE vp = (VALUE)p;
- if (RB_BUILTIN_TYPE(vp) != T_NONE) {
- rb_gc_obj_free(objspace, vp);
+ asan_unpoisoning_object(vp) {
+ if (RB_BUILTIN_TYPE(vp) != T_NONE) {
+ rb_gc_obj_free(objspace, vp);
+ }
}
}
}