Thanks to visit codestin.com
Credit goes to github.com

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

Merged
merged 4 commits into from
Jun 18, 2025
Merged

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 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.
@mame mame force-pushed the hide-internal-frames branch 2 times, most recently from ba6dcf0 to 905775a Compare June 18, 2025 02:59
mame added a commit to mame/irb that referenced this pull request Jun 18, 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.
@mame mame force-pushed the hide-internal-frames branch from 905775a to 52b3360 Compare June 18, 2025 03:49
@mame mame marked this pull request as ready for review June 18, 2025 04:32
mame added a commit to ruby/irb that referenced this pull request Jun 18, 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.
@mame mame force-pushed the hide-internal-frames branch from 52b3360 to b9ff12f Compare June 18, 2025 05:10
mame added 4 commits June 18, 2025 14:10
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 b9ff12f to c1464ba Compare June 18, 2025 05:10
@mame mame enabled auto-merge (rebase) June 18, 2025 05:10
@mame mame merged commit 2606a36 into ruby:master Jun 18, 2025
88 checks passed
@mame mame deleted the hide-internal-frames branch June 18, 2025 05:52
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