Opened 10 years ago

Closed 10 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/libroot.so Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

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 10 years ago.
arch_int.c_r28821.diff (486 bytes) - added by oco 10 years ago.
arch-specific.cpp_r28854.diff (401 bytes) - added by oco 10 years ago.

Download all attachments as: .zip

Change History (5)

Changed 10 years ago by oco

Attachment: test_mem.c added

Changed 10 years ago by oco

Attachment: arch_int.c_r28821.diff added

Changed 10 years ago by oco

comment:1 Changed 10 years ago by oco

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

comment:2 Changed 10 years ago by korli

Resolution: fixed
Status: newclosed

Applied in hrev29013

Note: See TracTickets for help on using tickets.