Opened 11 years ago

Closed 11 years ago

#3349 closed bug (fixed)

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
Priority: normal Milestone: R1
Component: System/ Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
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.

Attachments :

  • A C program to reproduce this problem
  • a patch to solve this problem

Attachments (3)

test_mem.c (402 bytes ) - added by oco 11 years ago.
arch_int.c_r28821.diff (486 bytes ) - added by oco 11 years ago.
arch-specific.cpp_r28854.diff (401 bytes ) - added by oco 11 years ago.

Download all attachments as: .zip

Change History (5)

by oco, 11 years ago

Attachment: test_mem.c added

by oco, 11 years ago

Attachment: arch_int.c_r28821.diff added

comment:1 by oco, 11 years ago

arch_int.c_r28821.diff is a mistake : please ignore...

comment:2 by korli, 11 years ago

Resolution: fixed
Status: newclosed

Applied in hrev29013

Note: See TracTickets for help on using tickets.