New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash after calling Kernel.initialize #3397

clayton-shopify opened this Issue Jan 11, 2017 · 0 comments


None yet
1 participant

clayton-shopify commented Jan 11, 2017

The following input demonstrates a crash:

loop do

This issue was reported by

I did some digging, and it appears the problem occurs because Kernel.initialize invokes mrb_mod_initialize, which calls boot_initmod. Then boot_initmod overwrites mod->mt if it already exists, which I suspect is causing a failure later on:

mod->mt = kh_init(mt, mrb);

The following patch checks whether mod->mt is already initialized, which appears to resolve the problem:

diff --git a/src/class.c b/src/class.c
index cb7bdfd..45827f5 100644
--- a/src/class.c
+++ b/src/class.c
@@ -915,7 +915,9 @@ boot_defclass(mrb_state *mrb, struct RClass *super)
 static void
 boot_initmod(mrb_state *mrb, struct RClass *mod)
-  mod->mt = kh_init(mt, mrb);
+  if (!mod->mt) {
+    mod->mt = kh_init(mt, mrb);
+  }

 static struct RClass*

@matz matz closed this in 38acb9e Jan 12, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment