Enhance documentation on malloc debug hooks
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 18 Mar 2016 10:04:31 +0000 (11:04 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Fri, 18 Mar 2016 10:04:31 +0000 (11:04 +0100)
Issue #26564, #26516, #26563.

Doc/c-api/memory.rst
Doc/using/cmdline.rst
Doc/whatsnew/3.6.rst

index 843ccac443f1718e58e7f0563d795b4932406034..178729248012561903006db48700535a4b5a0911 100644 (file)
@@ -346,8 +346,9 @@ Customize Memory Allocators
    - 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 @@ Customize Memory Allocators
    .. 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:
index 684ccb63de44a96ff609e3f2286d7985856e96a5..45559825b458c55b3b5ed34587ae7be6339315c1 100644 (file)
@@ -638,16 +638,20 @@ conflict.
    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
 
 
index 443e46a4755c1d707def1dc80dcd361acd841a96..411332fe17beafc79fc3e2802b6404bdbe5d6cf8 100644 (file)
@@ -118,8 +118,10 @@ compiled in release mode using ``PYTHONMALLOC=debug``. Effects of debug hooks:
 * 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.