Skip to content

Commit

Permalink
Don't clear out flags in rb_gc_obj_free
Browse files Browse the repository at this point in the history
If there's a crash after rb_gc_obj_free, it's hard to debug because the
flags have been cleared out already.
  • Loading branch information
peterzhu2118 committed Oct 21, 2024
1 parent 20c5a3e commit 5131fb5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,6 @@ rb_gc_obj_free(void *objspace, VALUE obj)
return FALSE;
}
else {
RBASIC(obj)->flags = 0;
return TRUE;
}
}
Expand Down
8 changes: 6 additions & 2 deletions gc/default.c
Original file line number Diff line number Diff line change
Expand Up @@ -3030,7 +3030,9 @@ rb_gc_impl_shutdown_free_objects(void *objspace_ptr)
VALUE vp = (VALUE)p;
asan_unpoisoning_object(vp) {
if (RB_BUILTIN_TYPE(vp) != T_NONE) {
rb_gc_obj_free(objspace, vp);
if (rb_gc_obj_free(objspace, vp)) {
RBASIC(vp)->flags = 0;
}
}
}
}
Expand Down Expand Up @@ -3102,7 +3104,9 @@ rb_gc_impl_shutdown_call_finalizer(void *objspace_ptr)
VALUE vp = (VALUE)p;
asan_unpoisoning_object(vp) {
if (rb_gc_shutdown_call_finalizer_p(vp)) {
rb_gc_obj_free(objspace, vp);
if (rb_gc_obj_free(objspace, vp)) {
RBASIC(vp)->flags = 0;
}
}
}
}
Expand Down

0 comments on commit 5131fb5

Please sign in to comment.