summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2024-10-21 10:25:34 -0400
committerPeter Zhu <[email protected]>2024-10-21 12:48:53 -0400
commit5131fb5dbe6565bd16883aad94b9daec8ec56c51 (patch)
tree4060dc97d782182bf1af27f0c28bbfd11826fa1a
parent20c5a3e1331cd177e0865aa104f41485153e34b1 (diff)
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.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/11925
-rw-r--r--gc.c1
-rw-r--r--gc/default.c8
2 files changed, 6 insertions, 3 deletions
diff --git a/gc.c b/gc.c
index dc17f3bf31..e67d1c0b8e 100644
--- a/gc.c
+++ b/gc.c
@@ -1314,7 +1314,6 @@ rb_gc_obj_free(void *objspace, VALUE obj)
return FALSE;
}
else {
- RBASIC(obj)->flags = 0;
return TRUE;
}
}
diff --git a/gc/default.c b/gc/default.c
index dac7aaeed6..50ad291081 100644
--- a/gc/default.c
+++ b/gc/default.c
@@ -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;
+ }
}
}
}
@@ -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;
+ }
}
}
}