rubymacososx-lionruby-cocoa

Segmentation fault on Lion creating NSData from RubyCocoa with any bytes > 127


The following RubyCocoa is fine on Max OS X 10.6, but segfaults on 10.7

require 'osx/cocoa'
include OSX
bytes = [128].pack('i1')
NSData.alloc.initWithBytes_length(bytes, bytes.length)

In all cases it works when the top bit is not set. In fact NSData.alloc seems to fail when passed a buffer where any of the bytes have the top bit set.

The version of Ruby is 1.8.7 on both OS's, so I'm at a loss to diagnose why NSData is interpreting the buffer differently. Can anyone shed any light?


Solution

  • This is fixed in RubyCocoa 1.0.2