Skip to content

Top frame from interpreter gets wrong filename #5849

@headius

Description

@headius

Example code:

required.rb:

puts caller(0)

test.rb:

require "./required.rb"

Output on JIT and interpreter:

[] ~/projects/jruby $ jruby test.rb
/Users/headius/projects/jruby/required.rb:1:in `<main>'
/Users/headius/projects/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1:in `require'
/Users/headius/projects/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1:in `(root)'
test.rb:1:in `<main>'

[] ~/projects/jruby $ jruby -X-C test.rb
/Users/headius/projects/jruby/required.rb:1:in `<main>'
/Users/headius/projects/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1:in `require'
/Users/headius/projects/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1:in `(root)'
/Users/headius/projects/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54:in `<main>'

I'm not sure why that top frame is getting screwed up. If we change the contents of required.rb to raise, the trace is also incorrect:

[] ~/projects/jruby $ jruby -Xbacktrace.style=mri test.rb
/Users/headius/projects/jruby/required.rb:1:in `<main>': unhandled exception
	from org/jruby/RubyKernel.java:987:in `require'
	from /Users/headius/projects/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1:in `(root)'
	from test.rb:1:in `<main>'

[] ~/projects/jruby $ jruby -Xbacktrace.style=mri -X-C test.rb
/Users/headius/projects/jruby/required.rb:1:in `<main>': unhandled exception
	from org/jruby/RubyKernel.java:987:in `require'
	from /Users/headius/projects/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1:in `(root)'
	from /Users/headius/projects/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54:in `<main>'

This is not specific to the MRI backtrace; the JRuby format also shows the problem. It seems like a top-level backtrace element is getting stomped on.

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