Exception in thread not printed

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 M., http://blog.wolfman.com


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

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

On Sun, Jun 22, 2008 at 12:55 AM, Jim M. [email protected] wrote:

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

Thanks


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

OK, I’ve took the liberty to file the issue myself:

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

(To be fixed shortly).

Thanks,
–Vladimir

On Mon, Jun 23, 2008 at 11:50 AM, Vladimir S. [email protected]
wrote:

–Vladimir

Description of problem…
=== Code: thread_bug.rb ====

   from bug.rb:4:in `new'

I’m happy to file a bug report if this indeed is a bug.
http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

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. :slight_smile:

Thanks,
–Vladimir

On Mon, Jun 23, 2008 at 4:31 PM, Vladimir S. [email protected]
wrote:

Hi Jim,

Thread.abort_on_exception= true
t.join
from bug.rb:4


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email