Skip to content

Commit c962735

Browse files
committed
Add missing write barrier in set_i_initialize_copy
When we copy the table from one set to another we need to run write barriers.
1 parent 4b80f56 commit c962735

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

set.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ set_i_initialize_copy(VALUE set, VALUE other)
528528

529529
set_free_embedded(sobj);
530530
set_copy(&sobj->table, RSET_TABLE(other));
531+
rb_gc_writebarrier_remember(set);
531532

532533
return set;
533534
}

test/ruby/test_set.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ def test_replace
129129
assert_same(set, ret)
130130
assert_equal(Set['a','b','c'], set)
131131

132+
set = Set[1,2]
133+
ret = set.replace(Set.new('a'..'c'))
134+
135+
assert_same(set, ret)
136+
assert_equal(Set['a','b','c'], set)
137+
132138
set = Set[1,2]
133139
assert_raise(ArgumentError) {
134140
set.replace(3)

0 commit comments

Comments
 (0)