mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
hash.c: fix WB miss issue in Hash#replace
* hash.c (rb_hash_replace): add a write barrier to fix GC mark miss on hashes using Hash#replace [Bug #9226] [ruby-core:58948] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8f77cfb308
commit
3dd248f13d
2 changed files with 8 additions and 16 deletions
|
@ -1,3 +1,8 @@
|
|||
Sun Dec 8 11:59:40 2013 Aman Gupta <ruby@tmm1.net>
|
||||
|
||||
* hash.c (rb_hash_replace): add a write barrier to fix GC mark miss on
|
||||
hashes using Hash#replace [Bug #9226] [ruby-core:58948]
|
||||
|
||||
Sun Dec 8 11:21:00 2013 Aman Gupta <ruby@tmm1.net>
|
||||
|
||||
* include/ruby/ruby.h: add RGENGC_WB_PROTECTED_NODE_CREF setting
|
||||
|
|
19
hash.c
19
hash.c
|
@ -1412,22 +1412,9 @@ rb_hash_replace(VALUE hash, VALUE hash2)
|
|||
|
||||
table2 = RHASH(hash2)->ntbl;
|
||||
|
||||
if (RHASH_EMPTY_P(hash2)) {
|
||||
rb_hash_clear(hash);
|
||||
if (table2) hash_tbl(hash)->type = table2->type;
|
||||
return hash;
|
||||
}
|
||||
|
||||
if (RHASH_ITER_LEV(hash) > 0) {
|
||||
rb_hash_clear(hash);
|
||||
hash_tbl(hash)->type = table2->type;
|
||||
rb_hash_foreach(hash2, replace_i, hash);
|
||||
}
|
||||
else {
|
||||
st_table *old_table = RHASH(hash)->ntbl;
|
||||
if (old_table) st_free_table(old_table);
|
||||
RHASH(hash)->ntbl = st_copy(table2);
|
||||
}
|
||||
rb_hash_clear(hash);
|
||||
hash_tbl(hash)->type = table2->type;
|
||||
rb_hash_foreach(hash2, replace_i, hash);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue