mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
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
2 changed files with 7 additions and 1 deletions
|
@ -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,8 +144,10 @@ wmap_compact(void *ptr)
|
|||
{
|
||||
struct weakmap *w = ptr;
|
||||
|
||||
if (w->table) {
|
||||
st_foreach(w->table, wmap_compact_table_i, (st_data_t)w->table);
|
||||
}
|
||||
}
|
||||
|
||||
static const rb_data_type_t weakmap_type = {
|
||||
"weakmap",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue