Skip to content

Exception backtrace is nil when it should be present #4467

@DavidEGrayson

Description

@DavidEGrayson

It looks like the performance improvements mentioned on the JRuby blog probably broke exception backtrace generation in some cases. This affected RSpec, causing the following bug: rspec/rspec-core#2299. I can reproduce the problem by running this very simple script in JRuby:

begin
  raise
rescue ArgumentError
rescue StandardError => e
  if e.backtrace.nil?
    puts "Rescued an exception with no backtrace!"
  else
    puts "Looks good"
  end
end

Here is a shell session showing my environment and the output of that script:

$ jruby -v
jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae Java HotSpot(TM) 64-Bit Server VM 25.121-b13 on 1.8.0_121-b13 +jit [mswin32-x86_64]
$ uname -a
MINGW64_NT-10.0 URANIUM 2.6.0(0.304/5/3) 2016-09-07 20:45 x86_64 Msys
$ jruby simple.rb
Rescued an exception with no backtrace!

MRI behaves as expected and prints "Looks good" when it runs that same script.

For anyone affected by this, a workaround is to add => _ to the first rescue statement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions