diff options
| author | Linus Torvalds <torvalds@g5.osdl.org> | 2005-08-02 20:34:24 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-08-02 20:34:24 -0700 |
| commit | 972609f0d10e3bcb10a9132802b2edb8b01d305f (patch) | |
| tree | 3751b70f1ead214ee556c4fd498395aab693f56c /compat | |
| parent | ac8ce3636d83e25d8a316fdce221e36c04c02dc1 (diff) | |
| download | sparse-dev-972609f0d10e3bcb10a9132802b2edb8b01d305f.tar.gz | |
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 3626cc73..1cab4dea 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 } |
