summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2002-04-30 07:54:25 +0000
committerjeff <jeff@FreeBSD.org>2002-04-30 07:54:25 +0000
commit21868731b084d3531fa8d1e49331719a427ff897 (patch)
tree1933c12e17d4de144c036ea868144a9d350ff76d /sys/kern
parent009ce05bfe3bd6bf626b80c1af34ea9d38fb180a (diff)
downloadFreeBSD-src-21868731b084d3531fa8d1e49331719a427ff897.zip
FreeBSD-src-21868731b084d3531fa8d1e49331719a427ff897.tar.gz
Add a new UMA debugging facility. This will overwrite freed memory with
0xdeadc0de and then check for it just before memory is handed off as part of a new request. This will catch any post free/pre alloc modification of memory, as well as introduce errors for anything that tries to dereference it as a pointer. This code takes the form of special init, fini, ctor and dtor routines that are specificly used by malloc. It is in a seperate file because additional debugging aids will want to live here as well.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_malloc.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index cfc4472..6ec1111 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -55,6 +55,7 @@
#include <vm/vm_map.h>
#include <vm/uma.h>
#include <vm/uma_int.h>
+#include <vm/uma_dbg.h>
#if defined(INVARIANTS) && defined(__i386__)
#include <machine/cpu.h>
@@ -386,8 +387,13 @@ kmeminit(dummy)
int size = kmemzones[indx].kz_size;
char *name = kmemzones[indx].kz_name;
- kmemzones[indx].kz_zone = uma_zcreate(name, size, NULL, NULL,
- NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_MALLOC);
+ kmemzones[indx].kz_zone = uma_zcreate(name, size,
+#ifdef INVARIANTS
+ trash_ctor, trash_dtor, trash_init, trash_fini,
+#else
+ NULL, NULL, NULL, NULL,
+#endif
+ UMA_ALIGN_PTR, UMA_ZONE_MALLOC);
for (;i <= size; i+= KMEM_ZBASE)
kmemsize[i >> KMEM_ZSHIFT] = indx;
OpenPOWER on IntegriCloud