diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-03-14 11:04:26 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-03-14 11:04:26 (GMT) |
commit | 34be807ca4dfecc5b0a9e577a48535e738dce32b (patch) | |
tree | 38e0e3860b3fabf2be4938330a1d0f37c5b169ab /Doc/whatsnew | |
parent | c877658d1ff5f93f3a2c7b5f0a7ac913b7374838 (diff) | |
download | cpython-34be807ca4dfecc5b0a9e577a48535e738dce32b.zip cpython-34be807ca4dfecc5b0a9e577a48535e738dce32b.tar.gz cpython-34be807ca4dfecc5b0a9e577a48535e738dce32b.tar.bz2 |
Add PYTHONMALLOC env var
Issue #26516:
* Add PYTHONMALLOC environment variable to set the Python memory
allocators and/or install debug hooks.
* PyMem_SetupDebugHooks() can now also be used on Python compiled in release
mode.
* The PYTHONMALLOCSTATS environment variable can now also be used on Python
compiled in release mode. It now has no effect if set to an empty string.
* In debug mode, debug hooks are now also installed on Python memory allocators
when Python is configured without pymalloc.
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r-- | Doc/whatsnew/3.6.rst | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst index 3afe2d4..588826b 100644 --- a/Doc/whatsnew/3.6.rst +++ b/Doc/whatsnew/3.6.rst @@ -80,6 +80,9 @@ Summary -- Release highlights PEP written by Carl Meyer +New Features +============ + .. _whatsnew-fstrings: PEP 498: Formatted string literals @@ -98,6 +101,34 @@ evaluated at run time, and then formatted using the :func:`format` protocol. See :pep:`498` and the main documentation at :ref:`f-strings`. +PYTHONMALLOC environment variable +--------------------------------- + +The new :envvar:`PYTHONMALLOC` environment variable allows to set the Python +memory allocators and/or install debug hooks. + +It is now possible to install debug hooks on Python memory allocators on Python +compiled in release mode using ``PYTHONMALLOC=debug``. Effects of debug hooks: + +* Newly allocated memory is filled with the byte ``0xCB`` +* Freed memory is filled with the byte ``0xDB`` +* Detect violations of Python memory allocator API. For example, + :c:func:`PyObject_Free` called on a memory block allocated by + :c:func:`PyMem_Malloc`. +* Detect write before the start of the buffer (buffer underflow) +* Detect write after the end of the buffer (buffer overflow) + +See the :c:func:`PyMem_SetupDebugHooks` function for debug hooks on Python +memory allocators. + +It is now also possible to force the usage of the :c:func:`malloc` allocator of +the C library for all Python memory allocations using ``PYTHONMALLOC=malloc``. +It helps to use external memory debuggers like Valgrind on a Python compiled in +release mode. + +(Contributed by Victor Stinner in :issue:`26516`.) + + Other Language Changes ====================== |