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

ruby-changes:63737

From: Takashi <ko1@a...>
Date: Tue, 24 Nov 2020 16:48:38 +0900 (JST)
Subject: [ruby-changes:63737] cfd8c7e6ca (master): Prefer calloc/free over ZALLOC/xfree

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

From cfd8c7e6ca9f923cee3a062b548d0824fc67e9a5 Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Mon, 23 Nov 2020 23:47:58 -0800
Subject: Prefer calloc/free over ZALLOC/xfree

To avoid SEGV like
http://ci.rvm.jp/logfiles/brlog.trunk-mjit.20201124-061530

diff --git a/mjit.c b/mjit.c
index 8f400f5..262298d 100644
--- a/mjit.c
+++ b/mjit.c
@@ -183,7 +183,10 @@ mjit_cont_new(rb_execution_context_t *ec) https://github.com/ruby/ruby/blob/trunk/mjit.c#L183
 {
     struct mjit_cont *cont;
 
-    cont = ZALLOC(struct mjit_cont);
+    // We need to use calloc instead of something like ZALLOC to avoid triggering GC here.
+    // When this function is called from rb_thread_alloc through rb_threadptr_root_fiber_setup,
+    // the thread is still being prepared and marking it causes SEGV.
+    cont = calloc(1, sizeof(struct mjit_cont));
     cont->ec = ec;
 
     CRITICAL_SECTION_START(3, "in mjit_cont_new");
@@ -218,7 +221,7 @@ mjit_cont_free(struct mjit_cont *cont) https://github.com/ruby/ruby/blob/trunk/mjit.c#L221
     }
     CRITICAL_SECTION_FINISH(3, "in mjit_cont_new");
 
-    xfree(cont);
+    free(cont);
 }
 
 // Finish work with continuation info.
-- 
cgit v0.10.2


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

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