diff options
author | Maxim Fedorov <maximfca@gmail.com> | 2021-05-22 22:32:36 -0700 |
---|---|---|
committer | Sverker Eriksson <sverker@erlang.org> | 2021-05-25 11:48:27 +0200 |
commit | ddbb46df7afb5d27d4db40bed33e900e18f2e350 (patch) | |
tree | 5026892d9ca278d54b4d084fc68dd694080a7c1f /erts/emulator/beam | |
parent | 2bcd9dca08421c6f961223cebf7b781aaf387a23 (diff) | |
download | erlang-ddbb46df7afb5d27d4db40bed33e900e18f2e350.tar.gz |
erts: Fix internal hash for external pids/ports
When 64-bit external pid and ports were introduced in OTP-24.0,
internal hash function was not adjusted accordingly. This led to a large
amount of hash collisions, ultimately making maps:from_list and
maps:from_keys to crash the emulator (stack overflow, or assertion
in a debug build).
Co-authored-by: Sverker Eriksson <sverker@erlang.org>
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r-- | erts/emulator/beam/utils.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c index 7df04420da..9947386efa 100644 --- a/erts/emulator/beam/utils.c +++ b/erts/emulator/beam/utils.c @@ -2343,23 +2343,15 @@ make_internal_hash(Eterm term, Uint32 salt) case EXTERNAL_PID_SUBTAG: { ExternalThing* thing = external_thing_ptr(term); /* See limitation #2 */ - #ifdef ARCH_64 POINTER_HASH(thing->node, HCONST_5); - UINT32_HASH(thing->data.ui[0], HCONST_5); - #else - UINT32_HASH_2(thing->node, thing->data.ui[0], HCONST_5); - #endif + UINT32_HASH_2(thing->data.pid.num, thing->data.pid.ser, HCONST_5); goto pop_next; } case EXTERNAL_PORT_SUBTAG: { ExternalThing* thing = external_thing_ptr(term); /* See limitation #2 */ - #ifdef ARCH_64 POINTER_HASH(thing->node, HCONST_6); - UINT32_HASH(thing->data.ui[0], HCONST_6); - #else - UINT32_HASH_2(thing->node, thing->data.ui[0], HCONST_6); - #endif + UINT32_HASH_2(thing->data.ui32[0], thing->data.ui32[1], HCONST_6); goto pop_next; } case FLOAT_SUBTAG: |