From: demallien <dem...@ma...> - 2011-08-03 09:59:11
|
Hi Duncan, I think you might be alone on this one - it may be time to move to MacRuby! As an interim workaround, you could try creating your own Objective-C wrapper class for NSData where you can verify that inputs coming from Ruby are what you expect. Allison On 01 Aug, 2011,at 09:26 PM, Duncan McGregor <du...@on...> wrote: Lion seems to have fundamentally broken RubyCocoa marshalling of binary data for me - viz : DESCRIPTION OF PROBLEM On Lion I cannot create NSData objects from RubyCocoa if any of the bytes have their top bit set. STEPS TO REPRODUCE The following code runs fine on 10.5 and 10.6, but segfaults in Lion (you can just paste it into an irb prompt). require 'osx/cocoa' include OSX byte = 128 bytes = [byte].pack('i_1') NSData.dataWithBytes_length(bytes, bytes.length) 10.6 gives #<OSX::NSConcreteData:0x801bf550 class='NSConcreteData' id=0x1013df110> 10.7 gives /System/Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50: [BUG] Segmentation fault ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0] NOTES AND ATTACHMENTS The code runs fine on 10.5 and 10.6 The code runs fine on 10.7 where byte < 128. The segfault happens on 10.7 if any of the bytes in the bytes string is > 127 The segfault also occurs when using CFDataCreate(0, bytes, bytes.length), NSData.dataWithRubyString, NSData.alloc.init*, NSMutableData.* - in fact, every way that I've tried to create an NSData, leading me to believe that the something very fundamental in the marshalling of strings as binary data is hosed. Has anyone else run into this issue, or am I the only person with who had a live RubyCocoa app? Cheers Duncan McGregor ------------------------------------------------------------------------------ BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA The must-attend event for mobile developers. Connect with experts. Get tools for creating Super Apps. See the latest technologies. Sessions, hands-on labs, demos & much more. Register early & save! http://p.sf.net/sfu/rim-blackberry-1 _______________________________________________ Rubycocoa-talk mailing list Rub...@li... https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk |