From 625a9838ee4e494d5c055986ceff66a32c38a05c Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Fri, 16 Nov 2018 19:49:11 +0100 Subject: erts: Fix offheap leak of ets catree tmp iteration key Also fix erts_debug:get_internal_status(node_and_dist_references) for catree to also search route node keys for offheap stuff. --- erts/emulator/beam/erl_db_catree.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'erts/emulator') diff --git a/erts/emulator/beam/erl_db_catree.c b/erts/emulator/beam/erl_db_catree.c index 153a720f07..b642ae009d 100644 --- a/erts/emulator/beam/erl_db_catree.c +++ b/erts/emulator/beam/erl_db_catree.c @@ -811,11 +811,12 @@ void destroy_root_iterator(CATreeRootIterator* iter) { if (iter->locked_bnode) unlock_iter_base_node(iter); - if (iter->search_key) + if (iter->search_key) { + destroy_route_key(iter->search_key); erts_free(ERTS_ALC_T_DB_TMP, iter->search_key); + } } - typedef struct { DbTableCATreeNode *parent; @@ -2069,6 +2070,23 @@ static SWord db_delete_all_objects_catree(Process* p, DbTable* tbl, SWord reds) } +static void do_for_route_nodes(DbTableCATreeNode* node, + void (*func)(ErlOffHeap *, void *), + void *arg) +{ + ErlOffHeap tmp_offheap; + + if (!GET_LEFT(node)->is_base_node) + do_for_route_nodes(GET_LEFT(node), func, arg); + + tmp_offheap.first = node->u.route.key.oh; + tmp_offheap.overhead = 0; + (*func)(&tmp_offheap, arg); + + if (!GET_RIGHT(node)->is_base_node) + do_for_route_nodes(GET_RIGHT(node), func, arg); +} + static void db_foreach_offheap_catree(DbTable *tbl, void (*func)(ErlOffHeap *, void *), void *arg) @@ -2083,6 +2101,8 @@ static void db_foreach_offheap_catree(DbTable *tbl, root = catree_find_next_root(&iter, NULL); } while (root); destroy_root_iterator(&iter); + + do_for_route_nodes(GET_ROOT(&tbl->catree), func, arg); } static int db_lookup_dbterm_catree(Process *p, DbTable *tbl, Eterm key, Eterm obj, -- cgit v1.2.3