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

[COMPILER] Seg fault on interpolated regex with once #2047

Closed
jemmaissroff opened this issue Dec 11, 2023 · 3 comments · Fixed by ruby/ruby#9207
Closed

[COMPILER] Seg fault on interpolated regex with once #2047

jemmaissroff opened this issue Dec 11, 2023 · 3 comments · Fixed by ruby/ruby#9207
Assignees
Labels
Milestone

Comments

@jemmaissroff
Copy link
Collaborator

There is a seg fault when we compile interpolated regex with the once flag.

Minimal repro to compile with Prism is here:

s = ""
/#{s}/o

I found this by running the following test:

RUBY_ISEQ_DUMP_DEBUG=prism make test/ruby/test_basicinstructions.rb

@eileencodes eileencodes self-assigned this Dec 11, 2023
@eileencodes
Copy link
Collaborator

I don't think this is related to once, it's just interpolation. I can get the same segv with the following:

s = 1
/#{s}/

I'll keep looking into it, just wanted to note that it's not once because we might see other failures that are related.

@eileencodes eileencodes changed the title [COMPILER] Seg fault on interpolated regex with once [COMPILER] Seg fault on interpolated regex Dec 12, 2023
@eileencodes
Copy link
Collaborator

Ugg, sorry I was running the wrong file. It is the once flag. Sorry for the noise 🤦🏼‍♀️

@eileencodes eileencodes changed the title [COMPILER] Seg fault on interpolated regex [COMPILER] Seg fault on interpolated regex with once Dec 12, 2023
@kddnewton kddnewton added this to the Ruby 3.3.0 milestone Dec 12, 2023
eileencodes added a commit to eileencodes/ruby that referenced this issue Dec 12, 2023
When you have an interpolated regex with a `once` flag and local
variable is outside the block created by the `once` flag, Prism would
see a segv. This is because it was not taking the depth into account.

To fix this, we need to add 1 to the `local_depth_offset` on the
`scope`.

Fixes: ruby/prism#2047
@eileencodes
Copy link
Collaborator

This should be fixed with ruby/ruby#9207

jemmaissroff pushed a commit to ruby/ruby that referenced this issue Dec 12, 2023
When you have an interpolated regex with a `once` flag and local
variable is outside the block created by the `once` flag, Prism would
see a segv. This is because it was not taking the depth into account.

To fix this, we need to add 1 to the `local_depth_offset` on the
`scope`.

Fixes: ruby/prism#2047
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants