From 8bbfae7b05df105bd8c57bf3f385b7c923874db5 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 27 Dec 2015 12:38:08 +0100 Subject: [PATCH] runtime_loader: Fix endless rld heap grow loop in edge case. The needed storage space for tracking the allocation size was not accounted for when growing the heap. Since the growth size is always rounded up to a multiple of 32KiB, this did almost never matter as the new allocation wouldn't need the full size. If the allocation did happen to need the full size however, the newly added area would always be too small. As the allocation attempt was simply restarted after each successful growth, this lead to an endless loop creating small new areas, which would then quickly starve the system for memory. --- src/system/runtime_loader/heap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/runtime_loader/heap.cpp b/src/system/runtime_loader/heap.cpp index 8cd57abf54..1c31616704 100644 --- a/src/system/runtime_loader/heap.cpp +++ b/src/system/runtime_loader/heap.cpp @@ -202,7 +202,7 @@ grow_heap(size_t bytes) { // align the area size to an 32768 bytes boundary bytes = (bytes + 32767) & ~32767; - return add_area(bytes); + return add_area(bytes + sizeof(size_t)); }