[haiku-commits] Re: r35478 - in haiku/trunk: headers/posix src/system/libroot/posix/malloc_debug

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 16 Feb 2010 00:03:40 +0100

On 2010-02-15 at 21:28:15 [+0100], mmlr@xxxxxxxx wrote:
> Author: mmlr
> Date: 2010-02-15 21:28:15 +0100 (Mon, 15 Feb 2010)
> New Revision: 35478
> Changeset: http://dev.haiku-os.org/changeset/35478/haiku
> 
> Modified:
>    haiku/trunk/headers/posix/malloc_debug.h
>    haiku/trunk/src/system/libroot/posix/malloc_debug/heap.cpp
> Log:
> * Add heap_debug_set_memory_reuse() which allows to disable memory reuse,
>   keeping all returned heap memory in the 0xdeadbeef state (including the
>   first sizeof(void *) bytes otherwise for the free list). While wasting a 
>   lot
>   of memory it allows you to rely on 0xdeadbeef being always present as no
>   future allocation will reuse the freed memory block.
> * Also added heap_debug_malloc_with_guard_page() which is intended to 
> allocate
>   a memory block so it is aligned that the start of invalid memory past the
>   allocation is in an unmapped guard page. However the kernel backend that 
>   would
>   guarantee this is not yet implemented, so right now this works only by 
>   chance
>   if no other area happens to be allocated exactly past the created one. 

You can use the POSIXy mprotect() (<sys/mman.h>) to change the page's 
protection to unaccessable.

CU, Ingo

Other related posts: