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

Fix corruption in ARGF.inplace #3409

Merged
merged 1 commit into from
Aug 12, 2020
Merged

Conversation

peterzhu2118
Copy link
Member

@peterzhu2118 peterzhu2118 commented Aug 11, 2020

Extension string stored in ARGF.inplace is created using an api designed for C string constants to create a Ruby string that points at another Ruby string. When the original string is swept, the extension string gets corrupted.

Reproduction script (on MacOS):

#!/usr/bin/ruby -pi.bak

BEGIN {
  GC.start(full_mark: true)
  arr = []
  1000000.times do |x|
    arr << "fooo#{x}"
  end
}

puts "hello"

Redmine ticket: https://bugs.ruby-lang.org/issues/17117

Co-Authored-By: Matt Valentine-House @eightbitraptor

@peterzhu2118 peterzhu2118 marked this pull request as ready for review August 11, 2020 19:10
@peterzhu2118 peterzhu2118 force-pushed the inplace-str-corruption branch 2 times, most recently from ceeb013 to f57b4b0 Compare August 11, 2020 20:47
Extension string stored in `ARGF.inplace` is created using an api designed for C string constants to create a Ruby string that points at another Ruby string. When the original string is swept, the extension string gets corrupted.

Reproduction script (on MacOS):

```

BEGIN {
  GC.start(full_mark: true)
  arr = []
  1000000.times do |x|
    arr << "fooo#{x}"
  end
}

puts "hello"
```

Co-Authored-By: Matt Valentine-House <31869+eightbitraptor@users.noreply.github.com>
@peterzhu2118 peterzhu2118 force-pushed the inplace-str-corruption branch from f57b4b0 to 2e4001d Compare August 12, 2020 02:42
@nobu nobu merged commit 166cacc into ruby:master Aug 12, 2020
@peterzhu2118 peterzhu2118 deleted the inplace-str-corruption branch August 12, 2020 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants