[MacRuby] #249: Attempting to modify instances of NSString or NSArray causes crash
#249: Attempting to modify instances of NSString or NSArray causes crash ---------------------------------+------------------------------------------ Reporter: jesper@… | Owner: lsansonetti@… 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: <http://www.macruby.org/trac/ticket/249> MacRuby <http://macruby.org/>
#249: Attempting to modify instances of NSString or NSArray causes crash ---------------------------------+------------------------------------------ Reporter: jesper@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ---------------------------------+------------------------------------------ Comment(by lsansonetti@…): 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 `<main>' }}} 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 `<main>' $ arch -x86_64 macruby -e "a = NSArray.array; a.clear" }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/249#comment:2> MacRuby <http://macruby.org/>
#249: Attempting to modify instances of NSString or NSArray causes crash ---------------------------------+------------------------------------------ Reporter: jesper@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: MacRuby 0.5 Component: MacRuby | Resolution: fixed Keywords: | ---------------------------------+------------------------------------------ Changes (by lsansonetti@…): * status: new => closed * resolution: => fixed * milestone: => MacRuby 0.5 Comment: Definitely fixed in trunk. {{{ $ ./miniruby -e "str = NSString.stringWithString 'a'; str << 'b'" can't modify frozen/immutable string (RuntimeError) }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/249#comment:3> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby