- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 33.3k
Open
Labels
pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtestsTests in the Lib/test dirTests in the Lib/test dirtopic-subinterpreterstype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
LeakSanitizer detects memory leaks when running test_import with the _testsinglephase module loaded in a subinterpreter.
How to Reproduce
Build:
CC=clang CXX=clang++ ./configure --disable-optimizations --with-pydebug --with-address-sanitizer && make -j$(nproc)Run:
./python -X dev -X showrefcount -m test test_import -j0Leak Summary
==643791==ERROR: LeakSanitizer: detected memory leaks
SUMMARY: AddressSanitizer: 6709 byte(s) leaked in 45 allocation(s).
Code Locations
The leaks originate from:
Subinterpreter execution:
- cpython/Modules/_testcapimodule.c - Line 1223 in e8e0f41 - r = PyRun_SimpleStringFlags(code, &cflags); 
 (- run_in_subinterp)
Module initialization:
- cpython/Modules/_testsinglephase.c - Line 516 in e8e0f41 - if (init_state(state) < 0) { 
 (- init__testsinglephase_basic)
- cpython/Modules/_testsinglephase.c - Line 303 in e8e0f41 - state->error = PyErr_NewException("_testsinglephase.error", NULL, NULL); 
 (- init_statewith- PyErr_NewException)
Import machinery:
- Line 429 in e8e0f41 - PyObject *m = p0(); 
 (- _PyImport_RunModInitFunc)
Leaked Objects
- Type objects (1016 bytes × 2): via type_new→PyErr_NewException
- Dictionary keys (424 bytes × 2): via new_keys_object→PyDict_SetItemString
- PyCMethod objects (384 bytes × 2 groups): via PyModule_AddFunctions
- Additional: Unicode strings, tuples, dictionaries
Full Output
See attached .log files for complete LeakSanitizer output for each version.
312.log
313.log
314.log
main.log
CPython versions tested on:
3.12, 3.13, 3.14, 3.15, CPython main branch
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Labels
pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtestsTests in the Lib/test dirTests in the Lib/test dirtopic-subinterpreterstype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
Todo