[MacRuby-devel] [MacRuby] #664: MacRuby Crashes When Scheduling a Block to Run on the Main Thread from a Background Thread

MacRuby ruby-noreply at macosforge.org
Tue Apr 27 16:53:07 PDT 2010


#664: MacRuby Crashes When Scheduling a Block to Run on the Main Thread from a
Background Thread
---------------------------------+------------------------------------------
 Reporter:  dylan@…              |       Owner:  lsansonetti@…        
     Type:  defect               |      Status:  new                  
 Priority:  blocker              |   Milestone:                       
Component:  MacRuby              |    Keywords:                       
---------------------------------+------------------------------------------
Description changed by martinlagardette@…:

Old description:

> Code:
>
> def main_thread( &block )
>   block.performSelectorOnMainThread( 'call', withObject: nil,
> waitUntilDone: true )
> end
>
> Thread.new do
>   main_thread do
>     [1,2,3].each {|i| puts i }
>   end
> end
>
> Expected result:
>
> Output numbers to the console.
>
> Actual result:
>
> -Terminal-
>
> macruby test.rb
> Assertion failed: (errorcode == 0), function setInstance, file
> ThreadLocal.cpp, line 61.
> Abort trap
>

> -XCode (have to run the code twice for some reason, first time works) -
>
> Assertion failed: ((b->flags & flags) == flags), function
> rb_vm_prepare_block, file dispatcher.cpp, line 1786.
> Program received signal:  “SIGABRT”.
>
> Backtrace (note that this was pasted into a ruby cocoa application and is
> triggered from a menu click):
>
> #0  0x00007fff81b35fe6 in __kill ()
> #1  0x00007fff81bd6e32 in abort ()
> #2  0x00007fff81bc3e74 in __assert_rtn ()
> #3  0x00000001001427e8 in rb_vm_prepare_block ()
> #4  0x000000010115a149 in ?? ()
> #5  0x0000000100149331 in rb_vm_block_eval ()
> #6  0x00007fff87ddc647 in __NSThreadPerformPerform ()
> #7  0x00007fff869c9271 in __CFRunLoopDoSources0 ()
> #8  0x00007fff869c7469 in __CFRunLoopRun ()
> #9  0x00007fff869c6c2f in CFRunLoopRunSpecific ()
> #10 0x00007fff80ca5a75 in _NSUnhighlightCarbonMenu ()
> #11 0x00007fff80f250b8 in -[NSMenu _internalPerformActionForItemAtIndex:]
> ()
> #12 0x00007fff80dd79d5 in -[NSCarbonMenuImpl
> _carbonCommandProcessEvent:handlerCallRef:] ()
> #13 0x00007fff80c84b60 in NSSLMMenuEventHandler ()
> #14 0x00007fff886f1bd7 in DispatchEventToHandlers ()
> #15 0x00007fff886f1126 in SendEventToEventTargetInternal ()
> #16 0x00007fff8870ed49 in SendEventToEventTarget ()
> #17 0x00007fff8873dd45 in SendHICommandEvent ()
> #18 0x00007fff8876aa1a in SendMenuCommandWithContextAndModifiers ()
> #19 0x00007fff8876a9d4 in SendMenuItemSelectedEvent ()
> #20 0x00007fff8876a8dc in FinishMenuSelection ()
> #21 0x00007fff8874bcf9 in MenuSelectCore ()
> #22 0x00007fff8874b461 in _HandleMenuSelection2 ()
> #23 0x00007fff80b55b79 in _NSHandleCarbonMenuEvent ()
> #24 0x00007fff80b296a2 in _DPSNextEvent ()
> #25 0x00007fff80b28b41 in -[NSApplication
> nextEventMatchingMask:untilDate:inMode:dequeue:] ()
> #26 0x00007fff80aee747 in -[NSApplication run] ()
> #27 0x00007fff80ae7468 in NSApplicationMain ()
> #28 0x0000000101147870 in ?? ()
> #29 0x000000010014c806 in rb_vm_dispatch ()
> #30 0x00000001011263e4 in ?? ()
> #31 0x000000010016115f in rb_vm_run ()
> #32 0x00000001000462a9 in ruby_run_node ()
> #33 0x00000001001614dc in macruby_main ()
> #34 0x0000000100001d40 in main (argc=1, argv=0x7fff5fbff5f0) at
> main.m:13
>
> Macruby Version:
>
> MacRuby version 0.6 (ruby 1.9.0) [universal-darwin10.0, x86_64]
> Nightly from 04/20/2010.
>
> test.rb attached

New description:

 Code:

 {{{
 #!ruby
 def main_thread( &block )
   block.performSelectorOnMainThread( 'call', withObject: nil,
 waitUntilDone: true )
 end

 Thread.new do
   main_thread do
     [1,2,3].each {|i| puts i }
   end
 end
 }}}

 Expected result:

 Output numbers to the console.

 Actual result:

 -Terminal-

 {{{
 $> macruby test.rb
 Assertion failed: (errorcode == 0), function setInstance, file
 ThreadLocal.cpp, line 61.
 Abort trap
 }}}

 -XCode (have to run the code twice for some reason, first time works) -

 {{{
 Assertion failed: ((b->flags & flags) == flags), function
 rb_vm_prepare_block, file dispatcher.cpp, line 1786.
 Program received signal:  “SIGABRT”.
 }}}

 Backtrace (note that this was pasted into a ruby cocoa application and is
 triggered from a menu click):

 {{{
 #0  0x00007fff81b35fe6 in __kill ()
 #1  0x00007fff81bd6e32 in abort ()
 #2  0x00007fff81bc3e74 in __assert_rtn ()
 #3  0x00000001001427e8 in rb_vm_prepare_block ()
 #4  0x000000010115a149 in ?? ()
 #5  0x0000000100149331 in rb_vm_block_eval ()
 #6  0x00007fff87ddc647 in __NSThreadPerformPerform ()
 #7  0x00007fff869c9271 in __CFRunLoopDoSources0 ()
 #8  0x00007fff869c7469 in __CFRunLoopRun ()
 #9  0x00007fff869c6c2f in CFRunLoopRunSpecific ()
 #10 0x00007fff80ca5a75 in _NSUnhighlightCarbonMenu ()
 #11 0x00007fff80f250b8 in -[NSMenu _internalPerformActionForItemAtIndex:]
 ()
 #12 0x00007fff80dd79d5 in -[NSCarbonMenuImpl
 _carbonCommandProcessEvent:handlerCallRef:] ()
 #13 0x00007fff80c84b60 in NSSLMMenuEventHandler ()
 #14 0x00007fff886f1bd7 in DispatchEventToHandlers ()
 #15 0x00007fff886f1126 in SendEventToEventTargetInternal ()
 #16 0x00007fff8870ed49 in SendEventToEventTarget ()
 #17 0x00007fff8873dd45 in SendHICommandEvent ()
 #18 0x00007fff8876aa1a in SendMenuCommandWithContextAndModifiers ()
 #19 0x00007fff8876a9d4 in SendMenuItemSelectedEvent ()
 #20 0x00007fff8876a8dc in FinishMenuSelection ()
 #21 0x00007fff8874bcf9 in MenuSelectCore ()
 #22 0x00007fff8874b461 in _HandleMenuSelection2 ()
 #23 0x00007fff80b55b79 in _NSHandleCarbonMenuEvent ()
 #24 0x00007fff80b296a2 in _DPSNextEvent ()
 #25 0x00007fff80b28b41 in -[NSApplication
 nextEventMatchingMask:untilDate:inMode:dequeue:] ()
 #26 0x00007fff80aee747 in -[NSApplication run] ()
 #27 0x00007fff80ae7468 in NSApplicationMain ()
 #28 0x0000000101147870 in ?? ()
 #29 0x000000010014c806 in rb_vm_dispatch ()
 #30 0x00000001011263e4 in ?? ()
 #31 0x000000010016115f in rb_vm_run ()
 #32 0x00000001000462a9 in ruby_run_node ()
 #33 0x00000001001614dc in macruby_main ()
 #34 0x0000000100001d40 in main (argc=1, argv=0x7fff5fbff5f0) at
 main.m:13
 }}}

 Macruby Version:

 MacRuby version 0.6 (ruby 1.9.0) [universal-darwin10.0, x86_64]
 Nightly from 04/20/2010.

 test.rb attached

--

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



More information about the MacRuby-devel mailing list