ruby/ruby-3.0.0-Do-not-allocate-ractor-local-storage-in-dfree-function-during-GC.patch
2021-03-02 11:05:16 +01:00

25 lines
664 B
Diff

From 265c0022390e3dcd4ff692fc77d29b94e652c877 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@ruby-lang.org>
Date: Tue, 9 Feb 2021 01:00:00 +0900
Subject: [PATCH] Do not allocate ractor-local storage in dfree function during
GC
---
random.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/random.c b/random.c
index c11cd803f2cb..83df6d1eb537 100644
--- a/random.c
+++ b/random.c
@@ -257,7 +257,8 @@ const rb_data_type_t rb_random_data_type = {
static void
random_mt_free(void *ptr)
{
- if (ptr != default_rand())
+ rb_random_mt_t *rnd = rb_ractor_local_storage_ptr(default_rand_key);
+ if (ptr != rnd)
xfree(ptr);
}