Skip to content

Commit 89d4943

Browse files
committed
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
1 parent 7a40f1f commit 89d4943

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ractor_sync.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,16 @@ ractor_sync_mark(rb_ractor_t *r)
660660
ractor_mark_monitors(r);
661661
}
662662

663+
static int
664+
ractor_sync_free_ports_i(st_data_t _key, st_data_t val, st_data_t _args)
665+
{
666+
struct ractor_queue *queue = (struct ractor_queue *)val;
667+
668+
ractor_queue_free(queue);
669+
670+
return ST_CONTINUE;
671+
}
672+
663673
static void
664674
ractor_sync_free(rb_ractor_t *r)
665675
{
@@ -669,6 +679,7 @@ ractor_sync_free(rb_ractor_t *r)
669679

670680
// maybe NULL
671681
if (r->sync.ports) {
682+
st_foreach(r->sync.ports, ractor_sync_free_ports_i, 0);
672683
st_free_table(r->sync.ports);
673684
r->sync.ports = NULL;
674685
}

0 commit comments

Comments
 (0)