[MacRuby] #876: EXC_BAD_ACCESS using IOBluetooth

MacRuby ruby-noreply at macosforge.org
Fri Jan 28 00:15:16 PST 2011


#876: EXC_BAD_ACCESS using IOBluetooth
-------------------------------------------+--------------------------------
 Reporter:  matt.wizeman@…                 |        Owner:  mattaimonetti@…        
     Type:  defect                         |       Status:  closed                 
 Priority:  critical                       |    Milestone:  MacRuby 0.9            
Component:  MacRuby                        |   Resolution:  invalid                
 Keywords:                                 |  
-------------------------------------------+--------------------------------
Changes (by mattaimonetti@…):

  * status:  new => closed
  * resolution:  => invalid
  * milestone:  MacRuby 1.0 => MacRuby 0.9


Comment:

 confirmed, here is the backtrace:

 {{{
 #0  0x00007fff8390b700 in _class_getSuperclass ()
 #1  0x00000001000f3b26 in rb_objc_convert_immediate ()
 #2  0x0000000100f219f7 in ?? ()
 #3  0x00007fff885d7d7a in -[IOBluetoothL2CAPChannel processIncomingData:]
 ()
 #4  0x00007fff885d670b in -[IOBluetoothL2CAPChannel handleMachMessage:] ()
 #5  0x00007fff822a8f47 in __NSFireMachPort ()
 #6  0x00007fff8567268e in __CFMachPortPerform ()
 #7  0x00007fff8564a6e1 in __CFRunLoopRun ()
 #8  0x00007fff85648dbf in CFRunLoopRunSpecific ()
 #9  0x00007fff81f8a93a in RunCurrentEventLoopInMode ()
 #10 0x00007fff81f8a73f in ReceiveNextEventCommon ()
 #11 0x00007fff81f8a5f8 in BlockUntilNextEventMatchingListInMode ()
 #12 0x00007fff827e7e64 in _DPSNextEvent ()
 #13 0x00007fff827e77a9 in -[NSApplication
 nextEventMatchingMask:untilDate:inMode:dequeue:] ()
 #14 0x00007fff827ad48b in -[NSApplication run] ()
 #15 0x00007fff827a61a8 in NSApplicationMain ()
 #16 0x0000000100f1dbcd in ?? ()
 #17 0x000000010014a7e8 in rb_vm_dispatch ()
 #18 0x0000000100f1c12c in ?? ()
 #19 0x0000000100f1b913 in ?? ()
 #20 0x0000000100163523 in rb_vm_run ()
 #21 0x0000000100040f80 in ruby_run_node ()
 #22 0x000000010015a872 in macruby_main ()
 #23 0x0000000100000efe in main (argc=1, argv=0x7fff5fbff7d0) at
 /Users/mattetti/tmp/wiimote-test/main.m:13
 }}}

 After further investigation, this is a bug in the sample code:

 {{{
         def openL2CAPChannelWithPSM(psm, delegate:delegate)
                 channel = Pointer.new_with_type("@")

                 if (@wiiDevice.openL2CAPChannelSync(channel, withPSM:psm,
 delegate:delegate) != KIOReturnSuccess)
                         closeConnection
                         return nil
                 end

                 channel[0]
         end
 }}}

 The channel local variable gets GC'd, to avoid that, use an instance
 variable to keep the pointer from being GC'd.

 {{{
         def openL2CAPChannelWithPSM(psm, delegate:delegate)
                 @channel = Pointer.new_with_type("@")

                 if (@wiiDevice.openL2CAPChannelSync(channel, withPSM:psm,
 delegate:delegate) != KIOReturnSuccess)
                         closeConnection
                         return nil
                 end

                 channel[0]
         end
 }}}

 I tested that here and everything is working fine. I think the confusion
 might be related to the fact that you might not have expected the pointer
 to be garbage collected.

 Feel free to reopen this ticket if my solution doesn't work for you.

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



More information about the macruby-tickets mailing list