diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-05-03 14:19:17 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-05-03 05:38:27 +0000 |
commit | 409a13e9ea018bbfa9dfc71c3427eff2dc4c4bd2 (patch) | |
tree | 8b3e8b630adda3709a053fca089a2b52c6c92283 /ext | |
parent | 32cc6301b375583c0aa7d8fea480628131e6a2aa (diff) | |
download | ruby-409a13e9ea018bbfa9dfc71c3427eff2dc4c4bd2.tar.gz |
[ruby/stringio] Update write-barrier at copying
http://ci.rvm.jp/results/trunk-asserts@ruby-sp2-docker/4552803
```
verify_internal_consistency_reachable_i: WB miss (O->Y) 0x00007f752ddd5550 [3LM ] strio (StringIO)strio -> 0x00007f752d19b7d0 [0 ] T_STRING (String) len: 8, capa: 15 "to_strio"
<internal:/tmp/ruby/src/trunk-asserts/lib/rubygems/core_ext/kernel_require.rb>:53: [BUG] gc_verify_internal_consistency: found internal inconsistency.
```
https://github.com/ruby/stringio/commit/2e8ab43cba
Diffstat (limited to 'ext')
-rw-r--r-- | ext/stringio/stringio.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 96e82ff5c1..99a19ead0d 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -698,15 +698,19 @@ strio_eof(VALUE self) static VALUE strio_copy(VALUE copy, VALUE orig) { - struct StringIO *ptr; + struct StringIO *ptr, *old_ptr; + VALUE old_string = Qundef; orig = rb_convert_type(orig, T_DATA, "StringIO", "to_strio"); if (copy == orig) return copy; ptr = StringIO(orig); - if (check_strio(copy)) { - strio_free(DATA_PTR(copy)); + old_ptr = check_strio(copy); + if (old_ptr) { + old_string = old_ptr->string; + strio_free(old_ptr); } DATA_PTR(copy) = ptr; + RB_OBJ_WRITTEN(copy, old_string, ptr->string); RBASIC(copy)->flags &= ~STRIO_READWRITE; RBASIC(copy)->flags |= RBASIC(orig)->flags & STRIO_READWRITE; ++ptr->count; |