Make WeakMap safe for compaction during allocation
During allocation, the table may not have been allocated yet which would crash in the st_foreach.
This commit is contained in:
parent
d313c82f79
commit
33cf8f640b
@ -237,6 +237,10 @@ class TestWeakMap < Test::Unit::TestCase
|
|||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_gc_compact_stress
|
||||||
|
EnvUtil.under_gc_compact_stress { ObjectSpace::WeakMap.new }
|
||||||
|
end
|
||||||
|
|
||||||
def test_replaced_values_bug_19531
|
def test_replaced_values_bug_19531
|
||||||
a = "A".dup
|
a = "A".dup
|
||||||
b = "B".dup
|
b = "B".dup
|
||||||
|
@ -144,7 +144,9 @@ wmap_compact(void *ptr)
|
|||||||
{
|
{
|
||||||
struct weakmap *w = ptr;
|
struct weakmap *w = ptr;
|
||||||
|
|
||||||
st_foreach(w->table, wmap_compact_table_i, (st_data_t)w->table);
|
if (w->table) {
|
||||||
|
st_foreach(w->table, wmap_compact_table_i, (st_data_t)w->table);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const rb_data_type_t weakmap_type = {
|
static const rb_data_type_t weakmap_type = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user