This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients lemburg, serhiy.storchaka, vstinner
Date 2016-03-09.11:15:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1457522115.12.0.78692190259.issue26516@psf.upfronthosting.co.za>
In-reply-to
Content
Attached patch:

- Add PYTHONMALLOC env var which accepts 4 values:

  * pymalloc: use pymalloc for PyObject_Malloc(), malloc for PyMem_Malloc() and PyMem_RawMalloc()
  * pymalloc_debug: pymalloc + debug hooks
  * malloc: use malloc for PyObject_Malloc(), PyMem_Malloc() and PyMem_RawMalloc()
  * malloc_debug: malloc + debug hooks

- Add support for debug hooks in release mode
- Add unit test for debug hooks in test_capi.py
- Add unit on misuse of memory allocators in test_capi.py

PYTHONMALLOC is used even if -E command line option is used, I prefer to keep the code simple. PYTHONMALLOC must be checked before the first call to any Python memory allocator, so it must occur very earlier. Well, it's simply the first instruction of main()...

My main use case is to be able to use debug hooks to detect:

* misuse of python memory allocators like object allocated with PyObject_Malloc() and freed with PyMem_Free()
* buffer overflow
* buffer underlow
History
Date User Action Args
2016-03-09 11:15:16vstinnersetrecipients: + vstinner, lemburg, serhiy.storchaka
2016-03-09 11:15:15vstinnersetmessageid: <1457522115.12.0.78692190259.issue26516@psf.upfronthosting.co.za>
2016-03-09 11:15:14vstinnerlinkissue26516 messages
2016-03-09 11:15:14vstinnercreate