Revision
3178
Author
lsansonetti@apple.com
Date
2009-12-30 21:29:46 -0800 (Wed, 30 Dec 2009)

Log Message

fixed a thread-safety bug in RoxorCore::retype_method()

Modified Paths

Diff

Modified: MacRuby/trunk/vm.cpp (3177 => 3178)


--- MacRuby/trunk/vm.cpp	2009-12-29 03:10:07 UTC (rev 3177)
+++ MacRuby/trunk/vm.cpp	2009-12-31 05:29:46 UTC (rev 3178)
@@ -1778,6 +1778,8 @@
 RoxorCore::retype_method(Class klass, rb_vm_method_node_t *node,
 	const char *types)
 {
+    lock();
+
     // TODO: 1) don't reinstall method in case the types didn't change
     // 2) free LLVM machine code from old objc IMP
 
@@ -1788,8 +1790,12 @@
     objc_to_ruby_stubs[node->ruby_imp] = node->objc_imp;
 
     // Re-add the method.
-    return add_method(klass, node->sel, node->objc_imp, node->ruby_imp,
+    node = add_method(klass, node->sel, node->objc_imp, node->ruby_imp,
 	    node->arity, node->flags, types);
+
+    unlock();
+
+    return node;
 }
 
 rb_vm_method_node_t *