From: Dave Barach Date: Tue, 31 Jul 2018 14:39:30 +0000 (-0400) Subject: Poison freed memory objects X-Git-Tag: v18.10-rc1~509 X-Git-Url: https://gerrit.fd.io/r/gitweb?p=vpp.git;a=commitdiff_plain;h=1c7bf5d41737984907e8bad1dc832eb6cb1d6288 Poison freed memory objects When compiled w/ -DCLIB_DEBUG=1, paint 0x13 across freed memory blocks. Should result in a characteristic SIGSEGV if someone dereferences a pointer in a freed vector element, etc. Change-Id: I5f78970f4342310bfbe7adeddb56feff21f0de2c Signed-off-by: Dave Barach --- diff --git a/src/vppinfra/dlmalloc.c b/src/vppinfra/dlmalloc.c index 8ae92cf566c..1bc8f656b66 100644 --- a/src/vppinfra/dlmalloc.c +++ b/src/vppinfra/dlmalloc.c @@ -4271,6 +4271,14 @@ void mspace_put (mspace msp, void *p_arg) mheap_put_trace ((u64)p_arg, psize); } +#if CLIB_DEBUG > 0 + /* Poison the object */ + { + size_t psize = mspace_usable_size (object_header); + memset (object_header, 0x13, psize); + } +#endif + /* And free it... */ mspace_free (msp, object_header); }