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

Skip to content

Push cme for dummy frame #13679

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 3 commits into from
Jun 24, 2025
Merged

Push cme for dummy frame #13679

merged 3 commits into from
Jun 24, 2025

Conversation

mame
Copy link
Member

@mame mame commented Jun 23, 2025

No description provided.

Follow up to fix 3b7373f.
In that commit, the line number in the first frame was overwritten after
the whole backtrace was created. There was a problem that the line
number was overwritten even if the location was backpatched.

Instead, this commit uses first_lineno if the frame is
VM_FRAME_MAGIC_DUMMY when generating the backtrace.

Before the patch:
```
$ ./miniruby -e '[1, 2].inject(:tap)'
-e:in '<main>': wrong number of arguments (given 1, expected 0) (ArgumentError)
        from -e:1:in 'Enumerable#inject'
        from -e:1:in '<main>'
```

After the patch:
```
$ ./miniruby -e '[1, 2].inject(:tap)'
-e:1:in '<main>': wrong number of arguments (given 1, expected 0) (ArgumentError)
        from -e:1:in 'Enumerable#inject'
        from -e:1:in '<main>'
```
@mame mame marked this pull request as ready for review June 23, 2025 14:35
@mame mame requested a review from ko1 June 23, 2025 14:35
Before the patch:
```
$ ./miniruby -e '[1, 2].inject(:tap)'
-e:1:in '<main>': wrong number of arguments (given 1, expected 0) (ArgumentError)
        from -e:1:in 'Enumerable#inject'
        from -e:1:in '<main>'
```

After the patch:
```
$ ./miniruby -e '[1, 2].inject(:tap)'
-e:1:in 'Kernel#tap': wrong number of arguments (given 1, expected 0) (ArgumentError)
        from -e:1:in 'Enumerable#inject'
        from -e:1:in '<main>'
```

Fixes https://bugs.ruby-lang.org/issues/20968#change-113811
@mame mame force-pushed the push-cme-for-dummy-frame branch from 0afb53a to 4aa98a2 Compare June 24, 2025 01:55
@mame
Copy link
Member Author

mame commented Jun 24, 2025

@ko1 said go ahead.

@mame mame merged commit 3546ced into ruby:master Jun 24, 2025
84 checks passed
@mame mame deleted the push-cme-for-dummy-frame branch June 24, 2025 02:40
yahonda added a commit to yahonda/rails that referenced this pull request Jun 25, 2025
This commit addresses the `TestERBTemplate#test_argument_error_in_the_template_is_not_hijacked_by_strict_locals_checking` failure
with Ruby 3.5.0dev including ruby/ruby@3546ced

- Without this commit:
```
$ cd actionview
$ ruby -v ; rm ../Gemfile.lock ; bundle ; bin/test test/template/template_test.rb:243
ruby 3.5.0dev (2025-06-24T02:39:58Z master 3546cedde3) +PRISM [x86_64-linux]
... snip ...

F

Failure:
TestERBTemplate#test_argument_error_in_the_template_is_not_hijacked_by_strict_locals_checking [test/template/template_test.rb:249]:
Expected /in ['`]hello'/ to match "/home/yahonda/src/github.com/rails/rails/actionview/test/template/template_test.rb:27:in 'TestERBTemplate::Context#hello'".

bin/test test/template/template_test.rb:243

Finished in 0.006231s, 160.4981 runs/s, 481.4942 assertions/s.
1 runs, 3 assertions, 1 failures, 0 errors, 0 skips
$
```

Here are `pp error.backtrace.first` differences between Ruby versions:

```ruby
$ git diff
diff --git a/actionview/test/template/template_test.rb b/actionview/test/template/template_test.rb
index e8fa3c8..688b5b1f0f 100644
--- a/actionview/test/template/template_test.rb
+++ b/actionview/test/template/template_test.rb
@@ -245,7 +245,7 @@ def test_argument_error_in_the_template_is_not_hijacked_by_strict_locals_checkin
       @template = new_template("<%# locals: () -%>\n<%= hello(:invalid_argument) %>")
       render
     end
-
+    pp error.backtrace.first
     assert_match(/in ['`].*hello'/, error.backtrace.first)
     assert_instance_of ArgumentError, error.cause
   end
$
```

- Ruby 3.3.8 `ruby 3.3.8 (2025-04-09 revision b200bad6cd) [x86_64-linux]`
"/home/yahonda/src/github.com/rails/rails/actionview/test/template/template_test.rb:27:in `hello'"

- Ruby 3.4.4 `ruby 3.4.4 (2025-05-14 revision a38531fd3f) +PRISM [x86_64-linux]`
"/home/yahonda/src/github.com/rails/rails/actionview/test/template/template_test.rb:27:in 'hello'"

- Ruby master `ruby 3.5.0dev (2025-06-24T02:39:58Z master 3546cedde3) +PRISM [x86_64-linux]`
"/home/yahonda/src/github.com/rails/rails/actionview/test/template/template_test.rb:27:in 'TestERBTemplate::Context#hello'"

Refer to:
ruby/ruby#13679
https://bugs.ruby-lang.org/issues/20968#change-113811
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