File 0765-Fix-offheap-check-of-emptied-ets-hash-table.patch of Package erlang

From d0cc5a316ba786577ee08ef4f1a2e1524e79bef3 Mon Sep 17 00:00:00 2001
From: Sverker Eriksson <sverker@erlang.org>
Date: Tue, 10 Sep 2019 18:51:37 +0200
Subject: [PATCH] Fix offheap check of emptied ets hash table

by erts_debug:get_internal_state(node_and_dist_references).

Table may be completely empty or trapping during segments deletion.
Only inspect the buckets that actually exists (tb->nslots).
---
 erts/emulator/beam/erl_db_hash.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/erts/emulator/beam/erl_db_hash.c b/erts/emulator/beam/erl_db_hash.c
index c6b6e66e3e..5937bd64ec 100644
--- a/erts/emulator/beam/erl_db_hash.c
+++ b/erts/emulator/beam/erl_db_hash.c
@@ -3216,6 +3216,12 @@ void db_foreach_offheap_hash(DbTable *tbl,
     int i;
     int nactive = NACTIVE(tb);
     
+    if (nactive > tb->nslots) {
+        /* Table is being emptied by delete/1 or delete_all_objects/1 */
+        ASSERT(!(tb->common.status & (DB_PRIVATE|DB_PROTECTED|DB_PUBLIC)));
+        nactive = tb->nslots;
+    }
+
     for (i = 0; i < nactive; i++) {
 	list = BUCKET(tb,i);
 	while(list != 0) {
-- 
2.16.4

openSUSE Build Service is sponsored by