[MacRuby] #1347: Segfault occurs when invoked a Module#define_method within some threads.
MacRuby
ruby-noreply at macosforge.org
Wed Jul 6 07:02:55 PDT 2011
#1347: Segfault occurs when invoked a Module#define_method within some threads.
----------------------------------+-----------------------------------------
Reporter: watson1978@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: blocker | Milestone:
Component: MacRuby | Keywords:
----------------------------------+-----------------------------------------
Comment(by watson1978@…):
To fix this problem and #1348, it looks like it would need to exclusive
control as following.
{{{
#!diff
diff --git a/vm.cpp b/vm.cpp
index eebda6d..fb57f37 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -1022,6 +1022,7 @@ RoxorCore::add_method(Class klass, SEL sel, IMP imp,
IMP ruby_imp,
real_node->sel = sel;
// Cache the implementation.
+ GET_CORE()->lock();
std::map<IMP, rb_vm_method_node_t *>::iterator iter2 =
ruby_imps.find(imp);
rb_vm_method_node_t *node;
if (iter2 == ruby_imps.end()) {
@@ -1033,6 +1034,7 @@ RoxorCore::add_method(Class klass, SEL sel, IMP imp,
IMP ruby_imp,
node = iter2->second;
assert(node->objc_imp == imp);
}
+ GET_CORE()->unlock();
node->klass = klass;
node->arity = arity;
node->flags = flags;
@@ -3052,7 +3054,7 @@ RoxorCore::gen_to_ocval_convertor(std::string type)
#endif
}
-static const int VM_LVAR_USES_SIZE = 8;
+static const int VM_LVAR_USES_SIZE = 16;
enum {
VM_LVAR_USE_TYPE_BLOCK = 1,
VM_LVAR_USE_TYPE_BINDING = 2
@@ -3072,6 +3074,7 @@ rb_vm_add_lvar_use(rb_vm_var_uses **var_uses, void
*use,
return;
}
+ GET_CORE()->lock();
if ((*var_uses == NULL)
|| ((*var_uses)->uses_count == VM_LVAR_USES_SIZE)) {
@@ -3087,6 +3090,7 @@ rb_vm_add_lvar_use(rb_vm_var_uses **var_uses, void
*use,
GC_WB(&(*var_uses)->uses[current_index], use);
(*var_uses)->use_types[current_index] = use_type;
++(*var_uses)->uses_count;
+ GET_CORE()->unlock();
}
extern "C"
}}}
MacRuby crashes If does not change VM_LVAR_USES_SIZE. but, I do not know
yet why it needs to change :(
--
Ticket URL: <http://www.macruby.org/trac/ticket/1347#comment:1>
MacRuby <http://macruby.org/>
More information about the macruby-tickets
mailing list