On 03/24/2015 03:28 PM, Karl Pickett wrote:
So we then tried running it under valgrind, and we got a lot of nasty errors. Even after reading the Misc/README.valgrind, which talks about *uninitialized* reads being ok, I still don't see how reading from *freed* memory would ever be safe, and why the suppression file thinks thats ok:
PyObject_Free() is not reading *freed* memory, it is reading memory outside (right before) the allocated range. This is, of course, undefined behavior as far as C is concerned and an invalid read in the eyes of valgrind. Still, it's the kind of thing you can get away with if you are writing a heavily optimized allocator (and if your name starts with "Tim" and ends with "Peters").
README.valgrind explains in quite some detail why this is done. In short, it allows for a very fast check whether the memory passed to PyObject_Free() was originally allocated by system malloc or by Python's pool allocator.
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com