зеркало из https://github.com/github/ruby.git
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:
Родитель
d313c82f79
Коммит
33cf8f640b
|
@ -237,6 +237,10 @@ class TestWeakMap < Test::Unit::TestCase
|
|||
end;
|
||||
end
|
||||
|
||||
def test_gc_compact_stress
|
||||
EnvUtil.under_gc_compact_stress { ObjectSpace::WeakMap.new }
|
||||
end
|
||||
|
||||
def test_replaced_values_bug_19531
|
||||
a = "A".dup
|
||||
b = "B".dup
|
||||
|
|
|
@ -144,7 +144,9 @@ wmap_compact(void *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 = {
|
||||
|
|
Загрузка…
Ссылка в новой задаче