Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Top frame from interpreter gets wrong filename #5849

Closed
headius opened this issue Aug 27, 2019 · 1 comment · Fixed by #5851
Closed

Top frame from interpreter gets wrong filename #5849

headius opened this issue Aug 27, 2019 · 1 comment · Fixed by #5851
Milestone

Comments

@headius
Copy link
Member

@headius headius commented Aug 27, 2019

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.

@headius

This comment has been minimized.

Copy link
Member Author

@headius headius commented Aug 27, 2019

Note the line numbers within kernel_require.rb are also wrong in JRuby. They should be line 54 and show method name require yet they're showing line 1 and one of them show (root).

headius added a commit to headius/jruby that referenced this issue Aug 28, 2019
All modes of Ruby execution handle their own backtrace and frame
pushing. The startup and full interpreters push both before they
begin executing. Compiled Ruby code pushes a frame only if needed,
and leans on the Java stack trace for its backtrace data. The
extra frames removed here are unnecessary overhead and muck up the
backtrace as shown in jrubyGH-5849.
@enebo enebo added this to the JRuby 9.2.9.0 milestone Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.