summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2026-01-31 08:53:48 +0100
committerJean Boussier <jean.boussier@gmail.com>2026-01-31 10:35:48 +0100
commitbd6fa7f5cca426901bc9162724966339440bc6cb (patch)
tree57363875f68945549cb9bc47b7e63950b1d5c6b0 /vm.c
parentdb52e98520349e2bfcd471a0c2f96d696a4f7498 (diff)
ruby_xfree: reject memory allocated by ruby_mimalloc
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/vm.c b/vm.c
index 2cae6779d9..f2e2ba1b89 100644
--- a/vm.c
+++ b/vm.c
@@ -3821,7 +3821,12 @@ thread_free(void *ptr)
else {
// ruby_xfree(th->nt);
// TODO: MN system collect nt, but without MN system it should be freed here.
- ruby_xfree(th);
+ if (th->main_thread) {
+ ruby_mimfree(th);
+ }
+ else {
+ ruby_xfree(th);
+ }
}
RUBY_FREE_LEAVE("thread");
@@ -4594,6 +4599,7 @@ Init_BareVM(void)
vm->global_hooks.type = hook_list_type_global;
// setup main thread
+ th->main_thread = 1;
th->nt = ZALLOC(struct rb_native_thread);
th->vm = vm;
th->ractor = vm->ractor.main_ractor = rb_ractor_main_alloc();