diff options
author | Peter Zhu <[email protected]> | 2025-06-03 11:33:03 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2025-06-03 15:48:38 -0400 |
commit | 89d49433a9229d13fa8df7945876a8b83413434c (patch) | |
tree | 886252b06fc016ca3bdf0ba6b229894fe6aff452 | |
parent | 7a40f1f06ce099455065dd98b2f8ce1d71946c6c (diff) |
Fix memory leak of Ractor ports
Memory leak reported:
3 miniruby 0x1044b6c1c ractor_init + 164 ractor.c:460
2 miniruby 0x1043fd6a0 ruby_xmalloc + 44 gc.c:5188
1 miniruby 0x104402840 rb_gc_impl_malloc + 148 default.c:8140
0 libsystem_malloc.dylib 0x19ab3912c _malloc_zone_malloc_instrumented_or_legacy + 152
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13504
-rw-r--r-- | ractor_sync.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/ractor_sync.c b/ractor_sync.c index 31ac2df4cf..0fcc293504 100644 --- a/ractor_sync.c +++ b/ractor_sync.c @@ -660,6 +660,16 @@ ractor_sync_mark(rb_ractor_t *r) ractor_mark_monitors(r); } +static int +ractor_sync_free_ports_i(st_data_t _key, st_data_t val, st_data_t _args) +{ + struct ractor_queue *queue = (struct ractor_queue *)val; + + ractor_queue_free(queue); + + return ST_CONTINUE; +} + static void ractor_sync_free(rb_ractor_t *r) { @@ -669,6 +679,7 @@ ractor_sync_free(rb_ractor_t *r) // maybe NULL if (r->sync.ports) { + st_foreach(r->sync.ports, ractor_sync_free_ports_i, 0); st_free_table(r->sync.ports); r->sync.ports = NULL; } |