diff options
-rw-r--r-- | erts/emulator/beam/external.c | 5 | ||||
-rw-r--r-- | erts/emulator/test/binary_SUITE.erl | 16 |
2 files changed, 20 insertions, 1 deletions
diff --git a/erts/emulator/beam/external.c b/erts/emulator/beam/external.c index 6bfd9fa825..7935acf6ba 100644 --- a/erts/emulator/beam/external.c +++ b/erts/emulator/beam/external.c @@ -4894,7 +4894,6 @@ dec_term_atom_common: (void) PSTACK_POP(hamt_array); } while (!PSTACK_IS_EMPTY(hamt_array)); - PSTACK_DESTROY(hamt_array); } /* Iterate through all the (flat)maps and check for validity and sort keys @@ -4906,6 +4905,9 @@ dec_term_atom_common: if (!erts_validate_and_sort_flatmap((flatmap_t*)next)) goto error; } + + /* Now that no more errors can occur, the stacks can be destroyed safely. */ + PSTACK_DESTROY(hamt_array); WSTACK_DESTROY(flat_maps); ASSERT((Eterm*)*dbg_resultp != NULL); @@ -5619,6 +5621,7 @@ init_done: if (n <= MAP_SMALL_MAP_LIMIT) { heap_size += 3 + n + 1 + n; } else { + CHKSIZE(2*n); /* Conservative size check */ heap_size += HASHMAP_ESTIMATED_HEAP_SIZE(n); } break; diff --git a/erts/emulator/test/binary_SUITE.erl b/erts/emulator/test/binary_SUITE.erl index 46434a8c1f..d8a4e6cddf 100644 --- a/erts/emulator/test/binary_SUITE.erl +++ b/erts/emulator/test/binary_SUITE.erl @@ -1442,6 +1442,22 @@ test_terms(Test_Func) -> Test_Func(FF = fun binary_SUITE:all/0), Test_Func(lists:duplicate(32, FF)), + %% Maps. + SmallMap = #{a => 1, b => 2, c => 3}, + LargeMap1 = maps:from_list([{list_to_atom(integer_to_list(36#cafe+N*N*N, 36)),N} || + N <- lists:seq(1, 33)]), + LargeMap2 = maps:from_list([{list_to_atom(integer_to_list(36#dead+N, 36)),N} || + N <- lists:seq(1, 50)]), + MapWithMap = LargeMap1#{SmallMap => a, LargeMap1 => LargeMap2, LargeMap2 => LargeMap1, + [LargeMap1,LargeMap2] => LargeMap1, + <<"abc">> => SmallMap, <<"qrs">> => LargeMap1, + <<"xyz">> => LargeMap2 }, + Test_Func(#{}), + Test_Func(SmallMap), + Test_Func(LargeMap1), + Test_Func(LargeMap2), + Test_Func(MapWithMap), + ok. test_floats(Test_Func) -> |