Skip to content

Commit 5131fb5

Browse files
committed
Don't clear out flags in rb_gc_obj_free
If there's a crash after rb_gc_obj_free, it's hard to debug because the flags have been cleared out already.
1 parent 20c5a3e commit 5131fb5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

gc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,6 @@ rb_gc_obj_free(void *objspace, VALUE obj)
13141314
return FALSE;
13151315
}
13161316
else {
1317-
RBASIC(obj)->flags = 0;
13181317
return TRUE;
13191318
}
13201319
}

gc/default.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3030,7 +3030,9 @@ rb_gc_impl_shutdown_free_objects(void *objspace_ptr)
30303030
VALUE vp = (VALUE)p;
30313031
asan_unpoisoning_object(vp) {
30323032
if (RB_BUILTIN_TYPE(vp) != T_NONE) {
3033-
rb_gc_obj_free(objspace, vp);
3033+
if (rb_gc_obj_free(objspace, vp)) {
3034+
RBASIC(vp)->flags = 0;
3035+
}
30343036
}
30353037
}
30363038
}
@@ -3102,7 +3104,9 @@ rb_gc_impl_shutdown_call_finalizer(void *objspace_ptr)
31023104
VALUE vp = (VALUE)p;
31033105
asan_unpoisoning_object(vp) {
31043106
if (rb_gc_shutdown_call_finalizer_p(vp)) {
3105-
rb_gc_obj_free(objspace, vp);
3107+
if (rb_gc_obj_free(objspace, vp)) {
3108+
RBASIC(vp)->flags = 0;
3109+
}
31063110
}
31073111
}
31083112
}

0 commit comments

Comments
 (0)