Skip to content

Fix corruption in ARGF.inplace#3409

Merged
nobu merged 1 commit intoruby:masterfrom
Shopify:inplace-str-corruption
Aug 12, 2020
Merged

Fix corruption in ARGF.inplace#3409
nobu merged 1 commit intoruby:masterfrom
Shopify:inplace-str-corruption

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants