{"record":{"id":"706c0e4d108b95a6","repo":"python/cpython","slug":"tracemalloc","errorCode":null,"errorMessage":"tracemalloc: ","messagePattern":"tracemalloc: ","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"Python/tracemalloc.c","lineNumber":85,"sourceCode":"#define tracemalloc_traced_memory _PyRuntime.tracemalloc.traced_memory\n#define tracemalloc_peak_traced_memory _PyRuntime.tracemalloc.peak_traced_memory\n#define tracemalloc_filenames _PyRuntime.tracemalloc.filenames\n#define tracemalloc_traceback _PyRuntime.tracemalloc.traceback\n#define tracemalloc_tracebacks _PyRuntime.tracemalloc.tracebacks\n#define tracemalloc_traces _PyRuntime.tracemalloc.traces\n#define tracemalloc_domains _PyRuntime.tracemalloc.domains\n\n\n#ifdef TRACE_DEBUG\nstatic void\ntracemalloc_error(const char *format, ...)\n{\n    va_list ap;\n    fprintf(stderr, \"tracemalloc: \");\n    va_start(ap, format);\n    vfprintf(stderr, format, ap);\n    va_end(ap);\n    fprintf(stderr, \"\\n\");\n    fflush(stderr);\n}\n#endif\n\n\n#define tracemalloc_reentrant_key _PyRuntime.tracemalloc.reentrant_key\n\n/* Any non-NULL pointer can be used */\n#define REENTRANT Py_True\n\nstatic int\nget_reentrant(void)\n{\n    assert(PyThread_tss_is_created(&tracemalloc_reentrant_key));\n\n    void *ptr = PyThread_tss_get(&tracemalloc_reentrant_key);\n    if (ptr != NULL) {\n        assert(ptr == REENTRANT);","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/python/cpython/blob/bc6749cc3b5ae4a5e88a6cc2d5b3bebbe354eae6/Python/tracemalloc.c#L67-L103","documentation":"This is the 'tracemalloc: ' prefix of tracemalloc_error(), a diagnostic helper in Python/tracemalloc.c that only compiles when TRACE_DEBUG is defined (it is not present in release or even normal --with-trace-refs builds). Messages prefixed with it report internal tracemalloc assertion/consistency problems (e.g. hash table corruption, unbalanced remove/get calls) while debugging the allocator tracer itself.","triggerScenarios":"Building CPython with -DTRACE_DEBUG and running with tracemalloc active (PYTHONTRACEMALLOC or -X tracemalloc); any internal invariant failure inside tracemalloc's hash table or filter logic prints via this helper.","commonSituations":"CPython core development debugging tracemalloc itself; custom patches to tracemalloc that broke invariants; almost never seen by application developers because the macro is undefined by default.","solutions":["If you are not developing CPython itself, rebuild without -DTRACE_DEBUG","For core dev: reproduce under a debugger, note the exact message after the prefix, and inspect the tracemalloc hash table state at the failure site","Check for memory corruption from third-party C extensions corrupting tracemalloc's tables"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Application developers: don't build with -DTRACE_DEBUG; it is a CPython-core diagnostics switch","Core developers: run tracemalloc test suites (test_tracemalloc) after touching its hash table code","Suspect memory-corrupting C extensions when internal tracemalloc invariants fail on a debug build"],"tags":["cpython","tracemalloc","debug-build","memory","internal"],"backgroundTag":null,"analyzedSha":"bc6749cc3b5ae4a5e88a6cc2d5b3bebbe354eae6","analyzedAt":"2026-08-14T22:01:13.976Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}