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.
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user