From 020681728717f8bb42c45e3a404daa6cc136c164 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Mon, 23 Mar 2026 17:50:12 -0700 Subject: [PATCH] Call xfree on TypedData_Make_Struct selectors TypedData_Make_Struct uses Ruby's xmalloc internally, so the corresponding free functions should call xfree rather than free. Ruby's xmalloc tracks allocation size internally so the GC knows how much memory is in use. In most release builds this justs causes this memory to be missed in accounting (causing extra GCs). However in debug builds in ruby 4.1dev the mismatched operations may crash. --- ext/io/event/selector/epoll.c | 2 +- ext/io/event/selector/kqueue.c | 2 +- ext/io/event/selector/uring.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/io/event/selector/epoll.c b/ext/io/event/selector/epoll.c index 6ef7a3f..0f50757 100644 --- a/ext/io/event/selector/epoll.c +++ b/ext/io/event/selector/epoll.c @@ -147,7 +147,7 @@ void IO_Event_Selector_EPoll_Type_free(void *_selector) IO_Event_Array_free(&selector->descriptors); - free(selector); + xfree(selector); } static diff --git a/ext/io/event/selector/kqueue.c b/ext/io/event/selector/kqueue.c index 49ad85b..9cab2c2 100644 --- a/ext/io/event/selector/kqueue.c +++ b/ext/io/event/selector/kqueue.c @@ -146,7 +146,7 @@ void IO_Event_Selector_KQueue_Type_free(void *_selector) IO_Event_Array_free(&selector->descriptors); - free(selector); + xfree(selector); } static diff --git a/ext/io/event/selector/uring.c b/ext/io/event/selector/uring.c index d342742..ae4d1fc 100644 --- a/ext/io/event/selector/uring.c +++ b/ext/io/event/selector/uring.c @@ -116,7 +116,7 @@ void IO_Event_Selector_URing_Type_free(void *_selector) IO_Event_Array_free(&selector->completions); - free(selector); + xfree(selector); } static