Not logged in
Log in now
Create an account
Subscribe to LWN
LWN.net Weekly Edition for May 23, 2013
An "enum" for Python 3
An unexpected perf feature
LWN.net Weekly Edition for May 16, 2013
A look at the PyPy 2.0 release
Detecting kernel memory leaks
Posted Jun 27, 2009 13:08 UTC (Sat) by nix (subscriber, #2304)
There are many tricks you can use: value pointing to a writably-mapped
region of the application's address space (very effective on x86-64, of
course), alignment on platforms where that matters...
Posted Jun 28, 2009 23:29 UTC (Sun) by epa (subscriber, #39769)
Posted Jun 29, 2009 0:10 UTC (Mon) by dlang (✭ supporter ✭, #313)
I don't think it's even a requirement that pointers be word aligned in memory, so you would have to look at every 4 byte sequence and calculate if it could be a pointer or not.
that's a _lot_ of calculations to waste your time on, even if you had a chance of being right 100% of the time.
Posted Jun 29, 2009 6:56 UTC (Mon) by nix (subscriber, #2304)
Posted Jun 29, 2009 7:40 UTC (Mon) by epa (subscriber, #39769)
if a garbage collector is looking at random bytes and trying to guess if they are pointers or not it's going to guess wrong a lot of the time.
Garbage collection in C and C++ can still be useful and fast, but it can never be 100% correct. This may not matter for many applications, but for programs like the kernel which need to be highly secure and must cope with untrusted user input (which could easily contain 32-bit or 64-bit ints carefully chosen to look like pointers), I suspect it does.
I wonder if there is a subset of C which provides the minimal guarantees needed to make garbage collection safe and complete. The main thing would be not to cast pointers to ints and back, nor to allow casting between pointers to things of different sizes, nor arbitrary pointer arithmetic (though arrays could still be provided).
Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds