A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2015-March/138906.html below:

[Python-Dev] How is obmalloc safe with "Invalid read of size 4" ?

[Python-Dev] How is obmalloc safe with "Invalid read of size 4" ?Hrvoje Niksic hrvoje.niksic at avl.com
Tue Mar 24 16:22:31 CET 2015
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.

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4