Skip to content

Commit

Permalink
Fix RUBY_FREE_AT_EXIT with ASAN
Browse files Browse the repository at this point in the history
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
  • Loading branch information
peterzhu2118 committed Jul 4, 2024
1 parent 478ada0 commit c480dec
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gc_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down

0 comments on commit c480dec

Please sign in to comment.