[MacRuby-devel] EXC_BAD_ACCESS When Reopening NSDate

Laurent Sansonetti lsansonetti at apple.com
Sat Feb 6 15:07:59 PST 2010


Your code causes an infinite loop. It's because you're calling #to_s  
recursively. It has nothing to do with re-opening NSDate.

The same happens with the original version of Ruby, BTW.

$ ruby19 -e "class Foo; def to_s; p '%p' % self; end; end; p Foo.new"
-e:1: stack level too deep (SystemStackError)

Laurent

On Feb 6, 2010, at 2:40 PM, steve ross wrote:

> This code creates an EXC_BAD_ACCESS error:
>
> class NSDate
>  def to_s
>    NSLog "#{__LINE__} NSDate#to_s %@", self
>    'hello'
>  end
> end
>
> NSDate.date.to_s
>
>
> If I change the NSLog statement to:
>
> NSLog "#{__LINE__} NSDate#to_s hello"
>
> Then I get the log entry and no EXC_BAD_ACCESS. Any idea what's  
> causing this?
>
> Thanks
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel



More information about the MacRuby-devel mailing list