mattn / mruby-uv

interface to libuv for mruby(experimental)
http://mattn.kaoriya.net/
92 stars 25 forks source link

MRB_NAN_BOXING has non-zero nil value #49

Closed AE9RB closed 10 years ago

AE9RB commented 10 years ago

thread.c must explicitly initialize once_info.block to nil for certain boxing types. Here's one possible solution:

diff --git a/src/thread.c b/src/thread.c
index 3006ca9..a36d4f2 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -567,6 +567,8 @@ void mrb_mruby_uv_gem_init_thread(mrb_state *mrb, struct RClass *UV)
   struct RClass* _class_uv_key;
   int const ai = mrb_gc_arena_save(mrb);

+  once_info.block = mrb_nil_value();
+
   _class_uv_thread = mrb_define_class_under(mrb, UV, "Thread", mrb->object_class);
   MRB_SET_INSTANCE_TT(_class_uv_thread, MRB_TT_DATA);
   mrb_define_module_function(mrb, _class_uv_thread, "self", mrb_uv_thread_self, ARGS_NONE());
take-cheeze commented 10 years ago

once_info.block is always initialized before calling uv_once so it should be fine. ( https://github.com/mattn/mruby-uv/blob/cae8153509ca771af124a11d277c15765120c649/src/thread.c#L309 ) Or is there a crash?

AE9RB commented 10 years ago

It crashes here: https://github.com/mattn/mruby-uv/blob/cae8153509ca771af124a11d277c15765120c649/src/thread.c#L306

take-cheeze commented 10 years ago

Ah sorry, that assert should be removed.

take-cheeze commented 10 years ago

Opened #50.