Make WeakKeyMap 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
33cf8f640b
commit
185b7e92a3
@ -123,6 +123,10 @@ class TestWeakKeyMap < Test::Unit::TestCase
|
|||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_gc_compact_stress
|
||||||
|
EnvUtil.under_gc_compact_stress { ObjectSpace::WeakKeyMap.new }
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def assert_weak_include(m, k, n = 100)
|
def assert_weak_include(m, k, n = 100)
|
||||||
|
@ -609,7 +609,9 @@ wkmap_compact(void *ptr)
|
|||||||
{
|
{
|
||||||
struct weakkeymap *w = ptr;
|
struct weakkeymap *w = ptr;
|
||||||
|
|
||||||
|
if (w->table) {
|
||||||
st_foreach_with_replace(w->table, wkmap_compact_table_i, wkmap_compact_table_replace, (st_data_t)0);
|
st_foreach_with_replace(w->table, wkmap_compact_table_i, wkmap_compact_table_replace, (st_data_t)0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const rb_data_type_t weakkeymap_type = {
|
static const rb_data_type_t weakkeymap_type = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user