[MacRuby-devel] [MacRuby] #249: Attempting to modify instances of NSString or NSArray causes crash

2009-05-06 Thread MacRuby
#249: Attempting to modify instances of NSString or NSArray causes crash
-+--
 Reporter:  jes...@… |   Owner:  lsansone...@…
 Type:  defect   |  Status:  new  
 Priority:  blocker  |   Milestone:   
Component:  MacRuby  |Keywords:   
-+--
 Creating an instance of NSString or NSArray, and then attempting to modify
 it, causes a crash in MacRuby 0.4 (built from source, revision 1541):

 {{{
 $ macirb
 irb(main):001:0> str = NSString.stringWithString 'a'
 => "a"
 irb(main):002:0> str << 'b'
 (irb):2: [BUG] Bus Error
 MacRuby version 0.4 (ruby 1.9.1) [universal-darwin9.5, x86_64]
 }}}

 {{{
 $ macirb
 irb(main):001:0> arr = NSArray.arrayWithObject 'a'
 => ["a"]
 irb(main):002:0> arr << 'b'
 
/Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.1/irb.rb:302:
 [BUG] Segmentation fault
 MacRuby version 0.4 (ruby 1.9.1) [universal-darwin9.5, x86_64]
 }}}

 (Yes, I know that NSString and NSArray are immutable types, but a bus
 error or segfault seems a bit harsh.)

-- 
Ticket URL: 
MacRuby 

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] [MacRuby] #249: Attempting to modify instances of NSString or NSArray causes crash

2009-05-06 Thread MacRuby
#249: Attempting to modify instances of NSString or NSArray causes crash
-+--
 Reporter:  jes...@… |   Owner:  lsansone...@…
 Type:  defect   |  Status:  new  
 Priority:  blocker  |   Milestone:   
Component:  MacRuby  |Keywords:   
-+--

Comment(by lsansone...@…):

 Thanks for the report, this is likely a bug in the YARV #<< optimization.
 We do check for mutability before doing any destructive operations.

 {{{
 $ macruby -e 's=NSString.string; s.strip!'
 -e:1:in `strip!': can't modify immutable string (RuntimeError)
 from -e:1:in `'
 }}}

 Also, I noticed that the check doesn't work for NSArray in 64-bit.

 {{{
 $ arch -i386 macruby -e "a = NSArray.array; a.clear"
 -e:1:in `clear': can't modify frozen/immutable array (RuntimeError)
 from -e:1:in `'
 $ arch -x86_64 macruby -e "a = NSArray.array; a.clear"
 }}}

-- 
Ticket URL: 
MacRuby 

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel