[MacRuby] #1347: Segfault occurs when invoked a Module#define_method within some threads.
MacRuby
ruby-noreply at macosforge.org
Wed Jul 6 08:34:54 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@…):
previous patch had been cause a deadlock :(
so, I rewrote a patch.
{{{
#!diff
diff --git a/vm.cpp b/vm.cpp
index eebda6d..9e37186 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -2672,8 +2672,10 @@ define_method:
char types[100];
resolve_method_type(types, sizeof types, klass, method, sel,
types_count);
+ GET_CORE()->lock();
node = GET_CORE()->add_method(klass, sel, objc_imp, ruby_imp, arity,
flags, types);
+ GET_CORE()->unlock();
if (!redefined) {
if (!genuine_selector && arity.max != arity.min) {
@@ -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"
}}}
To fix #1348, just change a VM_LVAR_USES_SIZE
--
Ticket URL: <http://www.macruby.org/trac/ticket/1347#comment:2>
MacRuby <http://macruby.org/>
More information about the macruby-tickets
mailing list