[Python-Dev] Invalid memory read in PyObject_Free (original) (raw)

Tim Peters tim.one@comcast.net
Sat, 5 Jul 2003 13:17:41 -0400


[Neal Norwitz]

... I never got around to submitting the attached patch which makes it easier and safer to use memory testing tools such as Purify and Valgrind. The suppression then only needs to be applied to ADDRESSINRANGE.

Please apply the patch, so that people can use this in 2.3 final. Nits:

decorations function_name(...

instead of like

decorations function_name(...

I haven't noticed a problem with pymalloc on Linux, Solaris, Tru64, AIX, HP-UX, FreeBSD. So far there haven't seemed to be any problems with pymalloc.

Its non-standard assumptions are mild. I don't know of any architecture now where a pointer can't be faithfully cast to some unsigned integral type. The biggest insecurity remaining then is addressed in a comment:

...

This comment in turn assumes that whatever memory protection gimmicks an OS implements are at page granularity. This assumption could be violated too by, e.g., an OS that resolved memory read permission to word (or even byte) boundaries, but I expect that's very rare due to lack of direct HW support.

Somtimes, there are benefits to turning off pymalloc from time to time in order to diagnose memory in use

Really? In a PYMALLOC_DEBUG build, and when the envar PYTHONMALLOCSTATS is set, pymalloc delivers an exact accounting of every byte pymalloc knows about. Even bytes "lost" to various alignment requirements are accounted for.

and some other memory related issues. Usually, pymalloc is a big win.

I agree .