From c480dec1ccf34b8452438811c5ef0f76cbb2a063 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Thu, 4 Jul 2024 09:25:50 -0400 Subject: 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 --- gc_impl.c | 6 ++++-- 1 file 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); + } } } } -- cgit v1.2.3