From 65b5e4d7ed880bb91a69b68e8e12b6d9178f2bb7 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Thu, 10 Sep 2009 02:09:16 +0000 Subject: [PATCH] Make use of the address range blocking to guarantee that accessing 0xdeadbeef and 0xcccccccc (and 64 pages thereafter) in any way will always lead to a crash. Before it could happen that these ranges were allocated for an area and then accessing these would not be as evident anymore. Only enabled when the corresponding paranoid setting is enabled (which it currently is). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33033 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/heap.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/system/kernel/heap.cpp b/src/system/kernel/heap.cpp index 42ff5a0354..d96f0ddac8 100644 --- a/src/system/kernel/heap.cpp +++ b/src/system/kernel/heap.cpp @@ -1912,6 +1912,15 @@ heap_init(addr_t base, size_t size) status_t heap_init_post_sem() { +#if PARANOID_KERNEL_MALLOC + vm_block_address_range("uninitialized heap memory", + (void *)ROUNDDOWN(0xcccccccc, B_PAGE_SIZE), B_PAGE_SIZE * 64); +#endif +#if PARANOID_KERNEL_FREE + vm_block_address_range("freed heap memory", + (void *)ROUNDDOWN(0xdeadbeef, B_PAGE_SIZE), B_PAGE_SIZE * 64); +#endif + sHeapGrowSem = create_sem(0, "heap_grow_sem"); if (sHeapGrowSem < 0) { panic("heap_init_post_sem(): failed to create heap grow sem\n");