[MacRuby] #1294: MacRuby crashes when loading files on the non-main thread

MacRuby ruby-noreply at macosforge.org
Wed Aug 31 01:27:11 PDT 2011


#1294: MacRuby crashes when loading files on the non-main thread
------------------------------------+---------------------------------------
 Reporter:  mrada@…                 |       Owner:  lsansonetti@…         
     Type:  defect                  |      Status:  new                   
 Priority:  blocker                 |   Milestone:                        
Component:  MacRuby                 |    Keywords:  reduction 0.11-blocker
------------------------------------+---------------------------------------

Comment(by lsansonetti@…):

 Following patch seems to fix the problem (for me, MBP quad-core), can
 someone else give it a try?

 {{{
 diff --git a/vm.cpp b/vm.cpp
 index a959bf0..8480414 100644
 --- a/vm.cpp
 +++ b/vm.cpp
 @@ -2464,6 +2464,8 @@ RoxorCore::copy_methods(Class from_class, Class
 to_class)
      Method *methods;
      unsigned int i, methods_count;

 +    lock();
 +
      // Copy existing Objective-C methods.
      methods = class_copyMethodList(from_class, &methods_count);
      if (methods != NULL) {
 @@ -2503,6 +2505,8 @@ RoxorCore::copy_methods(Class from_class, Class
 to_class)
         }
      }

 +    unlock();
 +
      // Force a resolving of these selectors on the target class. This
 must be
      // done outside the next loop since the resolver messes up the Core
      // structures.
 @@ -2512,6 +2516,8 @@ RoxorCore::copy_methods(Class from_class, Class
 to_class)
         class_getInstanceMethod(to_class, *iter);
      }

 +    lock();
 +
      // Now, let's really copy the lazy methods.
      std::vector<SEL> sels_to_add;
      for (std::vector<SEL>::iterator iter = sels_to_copy.begin();
 @@ -2533,7 +2539,9 @@ RoxorCore::copy_methods(Class from_class, Class
 to_class)

         rb_vm_method_source_t *m_src = iter2->second;

 +       unlock();
         Method m = class_getInstanceMethod(to_class, sel);
 +       lock();
         if (m != NULL) {
             // The method already exists on the target class, we need to
             // JIT it.
 @@ -2568,6 +2576,8 @@ RoxorCore::copy_methods(Class from_class, Class
 to_class)
         method_source_sels.insert(std::make_pair(to_class, *i));
      }
  #endif
 +
 +    unlock();
  }

  extern "C"
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/1294#comment:17>
MacRuby <http://macruby.org/>



More information about the macruby-tickets mailing list