[prev in list] [next in list] [prev in thread] [next in thread]
List: python-dev
Subject: Re: [Python-Dev] How is obmalloc safe with "Invalid read of size 4" ?
From: Hrvoje Niksic <hrvoje.niksic () avl ! com>
Date: 2015-03-24 15:22:31
Message-ID: 55118137.60108 () avl ! com
[Download RAW message or body]
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/python-dev-marcsub-zyf4%40marc.info
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic