summaryrefslogtreecommitdiff
path: root/ractor.c
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2024-07-16 09:41:10 -0400
committerPeter Zhu <[email protected]>2024-07-16 15:50:00 -0400
commitc083a3ffcd3b298784313c1617f2cf98f6fd27eb (patch)
tree9692e1ad5ba2b949586e5627093509f0bb020bcb /ractor.c
parentc4a021ef9606bb9777cd72fd716a6c89358465e0 (diff)
Fix memory leak reported in main ractor when RUBY_FREE_AT_EXIT
STACK OF 1 INSTANCE OF 'ROOT LEAK: <calloc in rb_ractor_main_alloc>': 6 dyld 0x1840e20e0 start + 2360 5 miniruby 0x1006796c8 main + 88 main.c:62 4 miniruby 0x10072f4a4 ruby_init + 16 eval.c:99 3 miniruby 0x10072f328 ruby_setup + 104 eval.c:81 2 miniruby 0x1008d08c0 Init_BareVM + 508 vm.c:4276 1 miniruby 0x1007f8944 rb_ractor_main_alloc + 76 ractor.c:2034 0 libsystem_malloc.dylib 0x1842a4cac _malloc_zone_calloc_instrumented_or_legacy + 128 ==== 1 (96 bytes) ROOT LEAK: <calloc in rb_ractor_main_alloc 0x1347075d0> [96]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/11175
Diffstat (limited to 'ractor.c')
-rw-r--r--ractor.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ractor.c b/ractor.c
index 2323f6b9eb..9d34dd1b7d 100644
--- a/ractor.c
+++ b/ractor.c
@@ -249,7 +249,12 @@ ractor_free(void *ptr)
ractor_local_storage_free(r);
rb_hook_list_free(&r->pub.hooks);
- RUBY_ASSERT(rb_free_at_exit || r->newobj_cache == NULL);
+ if (r->newobj_cache) {
+ RUBY_ASSERT(r == ruby_single_main_ractor);
+
+ rb_gc_ractor_cache_free(r->newobj_cache);
+ r->newobj_cache = NULL;
+ }
ruby_xfree(r);
}