From 35cf80447137caa8486ab58db702129bece5ba47 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Wed, 10 Apr 2019 10:50:53 +0200 Subject: [PATCH] base: free up all blocks on avl destruction Issue #3111 remove_range may deny to the job on memory pressure or insane ranges, which ends up in an endless loop when the Avl allocator is in destruction. Since the Avl gets destructed, solely the memory free up is of importance, not the correct range adjustments during remove_range. --- repos/base/src/lib/base/allocator_avl.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/repos/base/src/lib/base/allocator_avl.cc b/repos/base/src/lib/base/allocator_avl.cc index a58db6bd4..6aeb7fcbf 100644 --- a/repos/base/src/lib/base/allocator_avl.cc +++ b/repos/base/src/lib/base/allocator_avl.cc @@ -183,9 +183,13 @@ void Allocator_avl_base::_revert_allocations_and_ranges() (dangling_allocations > 1) ? "s" : "", " at allocator destruction time"); - /* remove ranges */ - while (Block *block = _addr_tree.first()) - remove_range(block->addr(), block->size()); + /* destroy all remaining blocks */ + while (Block *block = _addr_tree.first()) { + if (remove_range(block->addr(), block->size())) { + /* if the invocation fails, release the block to break endless loop */ + _destroy_block(block); + } + } }