diff options
author | 2005-08-02 20:34:24 -0700 | |
---|---|---|
committer | 2005-08-02 20:34:24 -0700 | |
commit | 972609f0d10e3bcb10a9132802b2edb8b01d305f (patch) | |
tree | 3751b70f1ead214ee556c4fd498395aab693f56c /compat | |
parent | Make types have file scope, not global scope (diff) | |
download | sparse-972609f0d10e3bcb10a9132802b2edb8b01d305f.tar.gz sparse-972609f0d10e3bcb10a9132802b2edb8b01d305f.tar.bz2 sparse-972609f0d10e3bcb10a9132802b2edb8b01d305f.zip |
Add DEBUG mode, which enables various expensive debug options
Right now it only makes 'blob_free()' mprotect(PROT_NONE) the buffer it
free's instead of unmapping it, but that's already quite useful for
figuring out when we've freed up memory that we later end up using after
all.
In particular, the multi-file mode ends up having different lifetime
rules for the various objects, so it introduced some nasty MM bugs.
With -DDEBUG we get some nice SIGSEGV's rather than just strange memory
corruption.
Diffstat (limited to 'compat')
-rw-r--r-- | compat/mmap-blob.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/compat/mmap-blob.c b/compat/mmap-blob.c index 3626cc7..1cab4de 100644 --- a/compat/mmap-blob.c +++ b/compat/mmap-blob.c @@ -29,5 +29,9 @@ void blob_free(void *addr, unsigned long size) { if (!size || (size & ~CHUNK) || ((unsigned long) addr & 512)) die("internal error: bad blob free (%lu bytes at %p)", size, addr); +#ifndef DEBUG munmap(addr, size); +#else + mprotect(addr, size, PROT_NONE); +#endif } |