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

ruby-changes:60181

From: Koichi <ko1@a...>
Date: Tue, 25 Feb 2020 13:39:00 +0900 (JST)
Subject: [ruby-changes:60181] 84d1a99a3f (master): should be initialize jit_unit->cc_entries.

https://git.ruby-lang.org/ruby.git/commit/?id=84d1a99a3f

From 84d1a99a3fc76b4bcd5fc382e5b30a466b124493 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Tue, 25 Feb 2020 13:37:52 +0900
Subject: should be initialize jit_unit->cc_entries.

GC can invoke just after allocation of jit_unit->cc_entries so
it should be zero-cleared.

diff --git a/iseq.c b/iseq.c
index 25f45a7..40be6c7 100644
--- a/iseq.c
+++ b/iseq.c
@@ -363,7 +363,9 @@ rb_iseq_mark(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L363
             // TODO: move to mjit.c?
             for (unsigned int i=0; i<body->ci_size; i++) {
                 const struct rb_callcache *cc = body->jit_unit->cc_entries[i];
-                rb_gc_mark((VALUE)cc); // pindown
+                if (cc != NULL) {
+                    rb_gc_mark((VALUE)cc); // pindown
+                }
             }
         }
 #endif
diff --git a/mjit.c b/mjit.c
index bcf773d..d2142d9 100644
--- a/mjit.c
+++ b/mjit.c
@@ -295,7 +295,7 @@ create_unit(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/mjit.c#L295
     unit->id = current_unit_num++;
     unit->iseq = (rb_iseq_t *)iseq;
     if (iseq->body->ci_size > 0) {
-        unit->cc_entries = ALLOC_N(const struct rb_callcache *, iseq->body->ci_size);
+        unit->cc_entries = ZALLOC_N(const struct rb_callcache *, iseq->body->ci_size);
     }
     iseq->body->jit_unit = unit;
 }
diff --git a/mjit_worker.c b/mjit_worker.c
index d074b7b..f55942e 100644
--- a/mjit_worker.c
+++ b/mjit_worker.c
@@ -1141,7 +1141,7 @@ mjit_copy_cache_from_main_thread(const rb_iseq_t *iseq, union iseq_inline_storag https://github.com/ruby/ruby/blob/trunk/mjit_worker.c#L1141
             if (iseq->body->jit_unit == NULL) rb_fatal("malloc failed");
             if (iseq->body->ci_size > 0) {
                 iseq->body->jit_unit->cc_entries =
-                  (const struct rb_callcache **)malloc(sizeof(const struct rb_callcache *) * iseq->body->ci_size);
+                  (const struct rb_callcache **)calloc(iseq->body->ci_size, sizeof(const struct rb_callcache *));
                 if (iseq->body->jit_unit->cc_entries == NULL) rb_fatal("malloc failed");
             }
         }
-- 
cgit v0.10.2


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

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