After an error while allocating a large memory space with sbrk, a small memory area could not be allocated anymore
|Reported by:||oco||Owned by:||axeld|
|Has a Patch:||no||Platform:||All|
A freepascal test case allocate a large space to check if the outofmemory exception is raised properly.
Under Haiku, i still use sbrk for memory allocation (like on beos as there was no mmap).
The exception is raised as expected, but it seems freepascal need some more memory to handle the exception, and this small allocation fail under Haiku (it works under BeOS).
I think we should restore previous heap size after an error when resizing the heap area. If not, the small allocation call will try to allocate the memory asked in the previous one + the small area. As the call has failed earlier, there is a good chance that resize_area will fail again with a little larger space asked.
- A C program to reproduce this problem
- a patch to solve this problem