[jruby-user] exception in thread not printed

2 views
Skip to first unread message

Jim Morris

unread,
Jun 21, 2008, 6:55:00 PM6/21/08
to us...@jruby.codehaus.org
Hi,

I'm not sure if this is a bug or "by design", I have seen some references that it may be by design.

The problem is it makes debugging very hard in jruby when a thread just dies with no error messages
printed.

Description of problem...

The following code has a typo, I am printing #{name} instead of #{@name}

What happens in JRuby is the thread dies with no error printed out.

Under C Ruby an error is printed out alerting me to my typo.

Without the `Thread.abort_on_exception= true' JRuby also prints out an error and both rubys do the
same thing.

=== Code: thread_bug.rb ====
Thread.abort_on_exception= true

@name= "my name"
t= Thread.new do
puts "thread starting..."
puts "this is a name #{name}"
puts "...exiting thread"
end

puts "waiting for thread"

t.join

puts "Program exiting"
=== end code ===

> ruby thread_bug.rb
thread starting...
bug.rb:6: undefined local variable or method `name' for #<Object:0xb7cd299c @name="my name"> (NameError)
from bug.rb:4:in `initialize'
from bug.rb:4:in `new'
from bug.rb:4
>

> /opt/jruby/bin/jruby bug.rb
waiting for thread
thread starting...
Program exiting

>

I'm happy to file a bug report if this indeed is a bug.

Thanks
Jim

--
Jim Morris, http://blog.wolfman.com

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

http://xircles.codehaus.org/manage_email


Vladimir Sizikov

unread,
Jun 23, 2008, 5:50:32 AM6/23/08
to us...@jruby.codehaus.org
Hi Jim,

Thanks for the report.

This looks like a clear bug to me, since JRuby's and MRI's behaviors
are different.
Please file a JIRA issue for that:
http://jira.codehaus.org/browse/JRUBY

Thanks,
--Vladimir

Vladimir Sizikov

unread,
Jun 23, 2008, 10:31:21 AM6/23/08
to us...@jruby.codehaus.org
OK, I've took the liberty to file the issue myself:

http://jira.codehaus.org/browse/JRUBY-2695

(To be fixed shortly).

Thanks,
--Vladimir

Vladimir Sizikov

unread,
Jun 23, 2008, 12:07:35 PM6/23/08
to us...@jruby.codehaus.org
Hi Jim,

The bug has been fixed and the fix will appear in JRuby 1.1.3, but you
could try out the current trunk for verification purposes. :)

Thanks,
--Vladimir

Reply all
Reply to author
Forward
0 new messages