[haiku-bugs] Re: [Haiku] #12438: Implement brk and sbrk

  • From: "korli" <trac@xxxxxxxxxxxx>
  • Date: Mon, 06 Jun 2016 12:02:13 -0000

#12438: Implement brk and sbrk
----------------------------+----------------------------
   Reporter:  simonsouth    |      Owner:  nobody
       Type:  enhancement   |     Status:  closed
   Priority:  normal        |  Milestone:  Unscheduled
  Component:  System/POSIX  |    Version:  R1/Development
 Resolution:  fixed         |   Keywords:
 Blocked By:                |   Blocking:
Has a Patch:  0             |   Platform:  All
----------------------------+----------------------------

Comment (by korli):

 What are FreePascal free memory expectations?

 I tested a bit, and the situation with ASLR enabled is chaotic, ie there
 isn't a contiguous data segment, the new sbrk implementation chooses the
 latest area, which can be libgcc_s data segment (which is weird BTW). But
 this isn't OK with ASLR disabled too on x86, the heap is hardcoded to
 384MB, which then limits the potential size for sbrk calls.
 It should be possible to simply reserve a higher address for the heap
 (here 1GB)

 {{{
 diff --git a/src/system/libroot/posix/malloc/arch-specific.cpp
 b/src/system/libroot/posix/malloc/arch-specific.cpp
 index 4167f04..bd00e12 100644
 --- a/src/system/libroot/posix/malloc/arch-specific.cpp
 +++ b/src/system/libroot/posix/malloc/arch-specific.cpp
 @@ -55,8 +55,8 @@ static const size_t kHeapIncrement = 16 * B_PAGE_SIZE;
  static const addr_t kHeapReservationBase = 0x1000000000;
  static const addr_t kHeapReservationSize = 0x1000000000;
  #else
 -static const addr_t kHeapReservationBase = 0x18000000;
 -static const addr_t kHeapReservationSize = 0x48000000;
 +static const addr_t kHeapReservationBase = 0x40000000;
 +static const addr_t kHeapReservationSize = 0x20000000;
  #endif

  static area_id sHeapArea;

 }}}

 There shouldn't be much impact: with ASLR enabled, the reservation base
 isn't taken into account anyway (the heap can be located before the
 program segment for instance...). With ASLR disabled, hoard should be able
 to allocate in the free range when it exhausts the reserved one, which
 would be limited to 512MB. Opinions?

 Another possibility is to check for an environment variable (like
 DISABLE_ASLR) to eventually place the initial heap area at the end of the
 address space.

 BTW does FreePascal load any libraries aside from libroot.so? That would
 also lead to problems (new impl of sbrk would pick these libraries data
 segments).

--
Ticket URL: <https://dev.haiku-os.org/ticket/12438#comment:10>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: