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 vstinner
Date 2016-03-15.00:39:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Python implements debug hooks on Python memory allocators:

Problem: buffer understand and buffer overflow are only detected when a memory block is released, which may occur far from the code responsible to create the buffer.

Attached patch dumps the traceback where a memory block was allocated on error in malloc debug hooks. The feature requires to enable tracemalloc to record tracebacks. used in below example:
import _testcapi

def f():


haypo@selma$ ./python -X tracemalloc=5 
Debug memory block at address p=0x22e8be0: API 'm'
    16 bytes originally requested
    The 7 pad bytes at p-7 are FORBIDDENBYTE, as expected.
    The 8 pad bytes at tail=0x22e8bf0 are not all FORBIDDENBYTE (0xfb):
        at tail+0: 0x78 *** OUCH
    The block was made by call #37240 to debug malloc/realloc.
    Data at p: cb cb cb cb cb cb cb cb cb cb cb cb cb cb cb cb

Memory block traceback (most recent call first):
  File "", line 4
  File "", line 6

Fatal Python error: bad trailing pad byte

Current thread 0x00007f4a93d9c700 (most recent call first):
  File "", line 4 in f
  File "", line 6 in <module>
Abandon (core dumped)

The patch adds the "Memory block traceback" section.
Date User Action Args
2016-03-15 00:39:56vstinnersetrecipients: + vstinner
2016-03-15 00:39:56vstinnersetmessageid: <>
2016-03-15 00:39:55vstinnerlinkissue26564 messages
2016-03-15 00:39:55vstinnercreate