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

Use real stack trace for autoload const location #7712

Merged
merged 1 commit into from Mar 14, 2023

Conversation

headius
Copy link
Member

@headius headius commented Mar 2, 2023

Autoload constants should show their assigned location as the point at which autoload was called. This was broken in the JIT because it depended on artificial Backtrace frames that JIT- compiled code does not populate.

This patch switches the logic to use a real generated backtrace frame, making it accurate in all cases.

This has the side effect of using our fully-canonicalized path from the backtrace as the file location of the constant, which may not match CRuby's uncanonicalized paths. This breaks the same CRuby test that was getting incorrect line numbers before:

  1. Failure:
    TestAutoload#test_source_location [/Users/headius/work/jruby/test/mri/ruby/test_autoload.rb:440]: <"/var/folders/h_/tmq357111c18sxbwlyq34mh80000gn/T/autoload20230302-39483-kwznu0/test-Bug16764.rb"> expected but was <"/private/var/folders/h_/tmq357111c18sxbwlyq34mh80000gn/T/autoload20230302-39483-kwznu0/test-Bug16764.rb">.

Fixes #7711 but introduces a new (minor?) incompatibility

Autoload constants should show their assigned location as the
point at which autoload was called. This was broken in the JIT
because it depended on artificial Backtrace frames that JIT-
compiled code does not populate.

This patch switches the logic to use a real generated backtrace
frame, making it accurate in all cases.

This has the side effect of using our fully-canonicalized path
from the backtrace as the file location of the constant, which
may not match CRuby's uncanonicalized paths. This breaks the same
CRuby test that was getting incorrect line numbers before:

  1) Failure:
TestAutoload#test_source_location [/Users/headius/work/jruby/test/mri/ruby/test_autoload.rb:440]:
<"/var/folders/h_/tmq357111c18sxbwlyq34mh80000gn/T/autoload20230302-39483-kwznu0/test-Bug16764.rb"> expected but was
<"/private/var/folders/h_/tmq357111c18sxbwlyq34mh80000gn/T/autoload20230302-39483-kwznu0/test-Bug16764.rb">.

Fixes jruby#7711 but introduces a new (minor?) incompatibility
@headius headius added this to the JRuby 9.4.3.0 milestone Mar 2, 2023
@headius headius merged commit 0fc2d19 into jruby:master Mar 14, 2023
56 checks passed
@headius headius deleted the real_backtrace_for_autoload_loc branch March 14, 2023 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Constants set by autoload have wrong line number in JIT
1 participant