[Python-checkins] cpython: Enhance documentation on malloc debug hooks

victor.stinner python-checkins at python.org
Fri Mar 18 06:04:41 EDT 2016


https://hg.python.org/cpython/rev/7b079adb0774
changeset:   100583:7b079adb0774
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Fri Mar 18 11:04:31 2016 +0100
summary:
  Enhance documentation on malloc debug hooks

Issue #26564, #26516, #26563.

files:
  Doc/c-api/memory.rst  |   9 ++++++---
  Doc/using/cmdline.rst |  16 ++++++++++------
  Doc/whatsnew/3.6.rst  |   6 ++++--
  3 files changed, 20 insertions(+), 11 deletions(-)


diff --git a/Doc/c-api/memory.rst b/Doc/c-api/memory.rst
--- a/Doc/c-api/memory.rst
+++ b/Doc/c-api/memory.rst
@@ -346,8 +346,9 @@
    - Detect write before the start of the buffer (buffer underflow)
    - Detect write after the end of the buffer (buffer overflow)
    - Check that the :term:`GIL <global interpreter lock>` is held when
-     allocator functions of the :c:data:`PYMEM_DOMAIN_OBJ` domain (ex:
-     :c:func:`PyObject_Malloc`) are called
+     allocator functions of :c:data:`PYMEM_DOMAIN_OBJ` (ex:
+     :c:func:`PyObject_Malloc`) and :c:data:`PYMEM_DOMAIN_MEM` (ex:
+     :c:func:`PyMem_Malloc`) domains are called
 
    On error, the debug hooks use the :mod:`tracemalloc` module to get the
    traceback where a memory block was allocated. The traceback is only
@@ -361,7 +362,9 @@
    .. versionchanged:: 3.6
       This function now also works on Python compiled in release mode.
       On error, the debug hooks now use :mod:`tracemalloc` to get the traceback
-      where a memory block was allocated.
+      where a memory block was allocated. The debug hooks now also check
+      if the GIL is hold when functions of :c:data:`PYMEM_DOMAIN_OBJ` and
+      :c:data:`PYMEM_DOMAIN_MEM` domains are called.
 
 
 .. _pymalloc:
diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst
--- a/Doc/using/cmdline.rst
+++ b/Doc/using/cmdline.rst
@@ -638,16 +638,20 @@
    Install debug hooks:
 
    * ``debug``: install debug hooks on top of the default memory allocator
-   * ``malloc_debug``: same than ``malloc`` but also install debug hooks
-   * ``pymalloc_debug``: same than ``malloc`` but also install debug hooks
+   * ``malloc_debug``: same as ``malloc`` but also install debug hooks
+   * ``pymalloc_debug``: same as ``pyalloc`` but also install debug hooks
+
+   When is compiled in release mode, the default is ``pymalloc``. When Python
+   is compiled in debug mode, the default is ``pymalloc_debug``: debug hooks
+   are installed.
+
+   If Python is configured without ``pymalloc`` support, ``pymalloc`` and
+   ``pymalloc_debug`` are not available, the default is ``malloc`` in release
+   mode and ``malloc_debug`` in debug mode.
 
    See the :c:func:`PyMem_SetupDebugHooks` function for debug hooks on Python
    memory allocators.
 
-   .. note::
-      ``pymalloc`` and ``pymalloc_debug`` are not available if Python is
-      configured without ``pymalloc`` support.
-
    .. versionadded:: 3.6
 
 
diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst
--- a/Doc/whatsnew/3.6.rst
+++ b/Doc/whatsnew/3.6.rst
@@ -118,8 +118,10 @@
 * Detect write before the start of the buffer (buffer underflow)
 * Detect write after the end of the buffer (buffer overflow)
 * Check that the :term:`GIL <global interpreter lock>` is held when allocator
-  functions of the :c:data:`PYMEM_DOMAIN_OBJ` domain (ex:
-  :c:func:`PyObject_Malloc`) are called
+  functions of :c:data:`PYMEM_DOMAIN_OBJ` (ex: :c:func:`PyObject_Malloc`) and
+  :c:data:`PYMEM_DOMAIN_MEM` (ex: :c:func:`PyMem_Malloc`) domains are called.
+
+Checking if the GIL is hold is also a new feature of Python 3.6.
 
 See the :c:func:`PyMem_SetupDebugHooks` function for debug hooks on Python
 memory allocators.

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list