aboutsummaryrefslogtreecommitdiffstats
path: root/mjit.c
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2020-11-23 23:47:58 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2020-11-23 23:48:06 -0800
commitcfd8c7e6ca9f923cee3a062b548d0824fc67e9a5 (patch)
tree0585dfb13e60d5d36814f791fd5bd4444fb4b63f /mjit.c
parent0deb06bfa41ff63a8ed732a690605d487b216378 (diff)
downloadruby-cfd8c7e6ca9f923cee3a062b548d0824fc67e9a5.tar.gz
Prefer calloc/free over ZALLOC/xfree
To avoid SEGV like http://ci.rvm.jp/logfiles/brlog.trunk-mjit.20201124-061530
Diffstat (limited to 'mjit.c')
-rw-r--r--mjit.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/mjit.c b/mjit.c
index 8f400f5f08..262298d6d4 100644
--- a/mjit.c
+++ b/mjit.c
@@ -183,7 +183,10 @@ mjit_cont_new(rb_execution_context_t *ec)
{
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)
}
CRITICAL_SECTION_FINISH(3, "in mjit_cont_new");
- xfree(cont);
+ free(cont);
}
// Finish work with continuation info.