[前][次][番号順一覧][スレッド一覧]

ruby-changes:63768

From: Koichi <ko1@a...>
Date: Fri, 27 Nov 2020 17:37:03 +0900 (JST)
Subject: [ruby-changes:63768] 5496415d31 (master): mark default_rand

https://git.ruby-lang.org/ruby.git/commit/?id=5496415d31

From 5496415d3165e57e3ade16238a4cc9ec2c3a81f6 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Fri, 27 Nov 2020 17:36:02 +0900
Subject: mark default_rand

default_rand can points a Bignum seed, so it should be marked.

diff --git a/ractor.c b/ractor.c
index a5f22a4..58f899e 100644
--- a/ractor.c
+++ b/ractor.c
@@ -200,6 +200,11 @@ ractor_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/ractor.c#L200
             rb_gc_mark(th->self);
         }
     }
+
+    if (r->default_rand) {
+        void rb_default_rand_mark(void *); // random.c
+        rb_default_rand_mark(r->default_rand);
+    }
 }
 
 static void
@@ -1773,7 +1778,10 @@ rb_ractor_default_rand(void *ptr) https://github.com/ruby/ruby/blob/trunk/ractor.c#L1778
 {
     if (rb_ractor_main_p()) {
         static void *default_rnd;
-        if (UNLIKELY(ptr != NULL)) default_rnd = ptr;
+        if (UNLIKELY(ptr != NULL)) {
+            rb_ractor_t *cr = GET_RACTOR();
+            cr->default_rand = default_rnd = ptr;
+        }
         return default_rnd;
     }
     else {
diff --git a/random.c b/random.c
index 22c5449..76183f9 100644
--- a/random.c
+++ b/random.c
@@ -158,6 +158,13 @@ default_rand(void) https://github.com/ruby/ruby/blob/trunk/random.c#L158
     return rnd;
 }
 
+void
+rb_default_rand_mark(void *ptr)
+{
+    rb_random_mt_t *rnd = (rb_random_mt_t *)ptr;
+    rb_gc_mark(rnd->base.seed);
+}
+
 static rb_random_mt_t *
 default_mt(void)
 {
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]