8000 Exclude internal frames from backtrace by mame · Pull Request #13238 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

Exclude internal frames from backtrace #13238

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 8000 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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mame
Copy link
Member
@mame mame commented May 2, 2025

This PR suppresses backtrace locations like <internal:array>:211 as much as possible.

Before the patch:

$ ruby -e '[1].fetch_values(42)'
<internal:array>:211:in 'Array#fetch': index 42 outside of array bounds: -1...1 (IndexError)
        from <internal:array>:211:in 'block in Array#fetch_values'
        from <internal:array>:211:in 'Array#map!'
        from <internal:array>:211:in 'Array#fetch_values'
        from -e:1:in '<main>'

After the patch:

$ ./miniruby -e '[1].fetch_values(42)'
-e:1:in 'Array#fetch_values': index 42 outside of array bounds: -1...1 (IndexError)
        from -e:1:in '<main>'

Specifically:

  • The special backtrace handling of BUILTIN_ATTR_C_TRACE is now always applied to frames with <internal:...>.
  • When multiple consecutive internal frames appear, all but the bottom (caller-side) frame are removed.

Fixes [Misc #20968]

mame added 3 commits June 4, 2025 19:55
In preparation for using it to update not only cfunc frames but also
internal frames, the function (and related variable names) are chagned.

I felt that the word "backpatch" is more appropriate than the more
general verb "update" here.
This changeset suppresses backtrace locations like
`<internal:array>:211` as much as possible.

Before the patch:
```
$ ruby -e '[1].fetch_values(42)'
<internal:array>:211:in 'Array#fetch': index 42 outside of array bounds: -1...1 (IndexError)
        from <internal:array>:211:in 'block in Array#fetch_values'
        from <internal:array>:211:in 'Array#map!'
        from <internal:array>:211:in 'Array#fetch_values'
        from -e:1:in '<main>'
```

After the patch:
```
$ ./miniruby -e '[1].fetch_values(42)'
-e:1:in 'Array#fetch_values': index 42 outside of array bounds: -1...1 (IndexError)
        from -e:1:in '<main>'
```

Specifically:

* The special backtrace handling of BUILTIN_ATTR_C_TRACE is now always
  applied to frames with `<internal:...>`.
* When multiple consecutive internal frames appear, all but the bottom
  (caller-side) frame are removed.

[Misc #20968]
@mame mame force-pushed the hide-internal-frames branch from 951718e to fdaf9c4 Compare June 4, 2025 11:08
mame added a commit to mame/debug that referenced this pull request Jun 4, 2025
In Ruby 3.5, `Kernel#caller_location` will not include `<internal:xxx>`
frames. ruby/ruby#13238

To skip the internal frames, explicitly check if `TracePoint#path` is a
internal path or not.
mame added a commit to mame/irb that referenced this pull request Jun 4, 2025
In ruby 3.5, `Kernel#caller_location` will not include `<internal:xxx>`
frames. Instead, it will use its caller-side location for an internal
frame. ruby/ruby#13238

This change updates the expected values of backtraces in irb test to
support the behavior change.

This comment has been minimized.

@mame mame force-pushed the hide-internal-frames branch from 9625778 to 60b3786 Compare June 4, 2025 17:26
ko1 pushed a commit to ruby/debug that referenced this pull request Jun 5, 2025
In Ruby 3.5, `Kernel#caller_location` will not include `<internal:xxx>`
frames. ruby/ruby#13238

To skip the internal frames, explicitly check if `TracePoint#path` is a
internal path or not.
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.

1 participant
0