Passing object with no 'to_s' method to IO#<< causes SystemStackError
---------------------------------------------------------------------

                 Key: JRUBY-1081
                 URL: http://jira.codehaus.org/browse/JRUBY-1081
             Project: JRuby
          Issue Type: Bug
    Affects Versions: JRuby 1.0.0RC2
         Environment: Solaris 10, Java 1.5, JRuby 2007-05-31 rev 3672
            Reporter: Daniel Berger
            Assignee: Thomas E Enebo


The IO#<< method relies on the .to_s method of the arguments passed to it . If 
that method is not defined, MRI simply raises a NoMethodError. JRuby, however, 
raises a SystemStackError. Here's an irb session that demonstrates:
{noformat}
irb(main):001:0> class Foo; end
=> nil
irb(main):002:0> STDOUT << Foo.new
#<Foo:0x15f7107>=> #<IO:0xf593af> # ok, no problem
irb(main):003:0> class Foo; undef_method :to_s; end
=> Foo
irb(main):004:0> STDOUT << Foo.new # blam!                 
/export/home/djberge/jruby/lib/ruby/1.8/irb/workspace.rb:51:in `eval': stack 
level too deep (SystemStackError)
        from /export/home/djberge/jruby/lib/ruby/1.8/irb/workspace.rb:81:in 
`evaluate'
        from /export/home/djberge/jruby/lib/ruby/1.8/irb/context.rb:219:in 
`evaluate'
        from /export/home/djberge/jruby/lib/ruby/1.8/irb.rb:150:in `eval_input'
        from /export/home/djberge/jruby/lib/ruby/1.8/irb.rb:70:in 
`signal_status'
        from /export/home/djberge/jruby/lib/ruby/1.8/irb.rb:189:in `eval_input'
        from /export/home/djberge/jruby/lib/ruby/1.8/irb.rb:70:in 
`each_top_level_statement'
        from /export/home/djberge/jruby/lib/ruby/1.8/irb.rb:190:in `loop'
        from /export/home/djberge/jruby/lib/ruby/1.8/irb/ruby-lex.rb:258:in 
`each_top_level_statement'
        from /export/home/djberge/jruby/lib/ruby/1.8/irb.rb:190:in `catch'
        from /export/home/djberge/jruby/lib/ruby/1.8/irb/ruby-lex.rb:259:in 
`each_top_level_statement'
        from /export/home/djberge/jruby/lib/ruby/1.8/irb.rb:190:in `eval_input'
        from /export/home/djberge/jruby/lib/ruby/1.8/irb.rb:70:in `start'
        from :-1:in `catch'
        from /export/home/djberge/jruby/lib/ruby/1.8/irb.rb:71:in `start'
        from :-
{noformat}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to