diff options
author | Peter Zhu <[email protected]> | 2024-10-21 10:25:34 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2024-10-21 12:48:53 -0400 |
commit | 5131fb5dbe6565bd16883aad94b9daec8ec56c51 (patch) | |
tree | 4060dc97d782182bf1af27f0c28bbfd11826fa1a | |
parent | 20c5a3e1331cd177e0865aa104f41485153e34b1 (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.c | 1 | ||||
-rw-r--r-- | gc/default.c | 8 |
2 files changed, 6 insertions, 3 deletions
@@ -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; + } } } } |