GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-140306: Fix memory leaks in cross-interpreter data handling by ashm-dev · Pull Request #140307 · python/cpython

Conversation

@ashm-dev

@ashm-dev ashm-dev commented Oct 18, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixes three memory leaks detected by LeakSanitizer in cross-interpreter operations:

  1. _interpchannelsmodule.c: Fixed bitwise AND (&) incorrectly used instead of OR (|) when combining XID_IGNORE_EXC and XID_FREE flags
  2. crossinterp.c (_release_xid_data): Fixed inverted ternary operator logic causing memory to be freed when it shouldn't and vice versa
  3. crossinterp.c (_PyXI_InitFailure): Added missing PyMem_RawFree() call in error path

Reduced memory leaks from 1565 bytes to 0 bytes in test__interpchannels.

  • Issue: Memory leak in test__interpchannels: _PyXIData_New not freed in channel_send #140306

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ashm-dev
pythongh-140306: Fix memory leaks in cross-interpreter data handling
122ac6c
@ashm-dev
ashm-dev requested a review from ericsnowcurrently as a code owner October 18, 2025 18:30
@bedevere-app bedevere-app Bot mentioned this pull request Oct 18, 2025
Memory leak in test__interpchannels: _PyXIData_New not freed in channel_send #140306
Closed
@bedevere-app bedevere-app Bot added the awaiting review label Oct 18, 2025
@ashm-dev

ashm-dev commented Oct 18, 2025

Copy link
Copy Markdown
Contributor Author
Before

Using random seed: 2825785630
0:00:00 load avg: 1.82 Run 1 test in parallel using 1 worker process
0:00:03 load avg: 1.82 [1/1/1] test__interpchannels worker non-zero exit code (Exit code 1)
[0 refs, 0 blocks]

=================================================================
==1082905==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1088 byte(s) in 17 object(s) allocated from:
    #0 0x60b0de3a54dd in calloc (/home/shamil/oss/cpython/main/python+0x9b34dd) (BuildId: 37792df6365e32052bfc7119c6be4df8fae85e76)
    #1 0x60b0de96628f in _PyMem_DebugRawAlloc /home/shamil/oss/cpython/main/Objects/obmalloc.c:2884:24
    #2 0x60b0deda055c in _PyXIData_New /home/shamil/oss/cpython/main/Python/crossinterp.c:309:24
    #3 0x6f4afa7ba621 in channel_send /home/shamil/oss/cpython/main/./Modules/_interpchannelsmodule.c:1797:25
    #4 0x6f4afa7aef84 in channelsmod_send /home/shamil/oss/cpython/main/./Modules/_interpchannelsmodule.c:3162:15
    #5 0x60b0de8fec4a in cfunction_call /home/shamil/oss/cpython/main/Objects/methodobject.c:564:18
    #6 0x60b0de7746be in _PyObject_MakeTpCall /home/shamil/oss/cpython/main/Objects/call.c:242:18
    #7 0x60b0dec8c537 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:2920:35
    #8 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #9 0x60b0de784063 in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/./Include/internal/pycore_call.h:169:11
    #10 0x60b0de7803dd in method_vectorcall /home/shamil/oss/cpython/main/Objects/classobject.c:95:18
    #11 0x60b0de77692b in _PyVectorcall_Call /home/shamil/oss/cpython/main/Objects/call.c:273:16
    #12 0x60b0dec70b70 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:2616:32
    #13 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #14 0x60b0de77415e in _PyObject_VectorcallDictTstate /home/shamil/oss/cpython/main/Objects/call.c:135:15
    #15 0x60b0de777e2d in _PyObject_Call_Prepend /home/shamil/oss/cpython/main/Objects/call.c:504:24
    #16 0x60b0de9f0fe7 in call_method /home/shamil/oss/cpython/main/Objects/typeobject.c:3076:19
    #17 0x60b0de7746be in _PyObject_MakeTpCall /home/shamil/oss/cpython/main/Objects/call.c:242:18
    #18 0x60b0dec51bd5 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:4021:35
    #19 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #20 0x60b0de784063 in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/./Include/internal/pycore_call.h:169:11
    #21 0x60b0de7803dd in method_vectorcall /home/shamil/oss/cpython/main/Objects/classobject.c:95:18
    #22 0x60b0de77692b in _PyVectorcall_Call /home/shamil/oss/cpython/main/Objects/call.c:273:16
    #23 0x60b0dec70b70 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:2616:32
    #24 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #25 0x60b0de77415e in _PyObject_VectorcallDictTstate /home/shamil/oss/cpython/main/Objects/call.c:135:15
    #26 0x60b0de777e2d in _PyObject_Call_Prepend /home/shamil/oss/cpython/main/Objects/call.c:504:24
    #27 0x60b0de9f0fe7 in call_method /home/shamil/oss/cpython/main/Objects/typeobject.c:3076:19
    #28 0x60b0de7746be in _PyObject_MakeTpCall /home/shamil/oss/cpython/main/Objects/call.c:242:18
    #29 0x60b0dec51bd5 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:4021:35

Direct leak of 192 byte(s) in 3 object(s) allocated from:
    #0 0x60b0de3a54dd in calloc (/home/shamil/oss/cpython/main/python+0x9b34dd) (BuildId: 37792df6365e32052bfc7119c6be4df8fae85e76)
    #1 0x60b0de96628f in _PyMem_DebugRawAlloc /home/shamil/oss/cpython/main/Objects/obmalloc.c:2884:24
    #2 0x60b0deda055c in _PyXIData_New /home/shamil/oss/cpython/main/Python/crossinterp.c:309:24
    #3 0x6f4afa7ba621 in channel_send /home/shamil/oss/cpython/main/./Modules/_interpchannelsmodule.c:1797:25
    #4 0x6f4afa7aef84 in channelsmod_send /home/shamil/oss/cpython/main/./Modules/_interpchannelsmodule.c:3162:15
    #5 0x60b0de8fec4a in cfunction_call /home/shamil/oss/cpython/main/Objects/methodobject.c:564:18
    #6 0x60b0de7746be in _PyObject_MakeTpCall /home/shamil/oss/cpython/main/Objects/call.c:242:18
    #7 0x60b0dec8c537 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:2920:35
    #8 0x60b0dec3c23c in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #9 0x60b0dec3c23c in PyEval_EvalCode /home/shamil/oss/cpython/main/Python/ceval.c:884:21
    #10 0x6f4afa740195 in _run_script /home/shamil/oss/cpython/main/./Modules/_interpretersmodule.c:632:24
    #11 0x6f4afa740195 in _run_in_interpreter /home/shamil/oss/cpython/main/./Modules/_interpretersmodule.c:690:15
    #12 0x6f4afa73d39d in _interpreters_run_string_impl /home/shamil/oss/cpython/main/./Modules/_interpretersmodule.c:1202:15
    #13 0x6f4afa73d39d in _interpreters_run_string /home/shamil/oss/cpython/main/./Modules/clinic/_interpretersmodule.c.h:531:20
    #14 0x60b0de773d6e in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/./Include/internal/pycore_call.h:169:11
    #15 0x60b0dec904bc in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:1620:35
    #16 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #17 0x60b0de784063 in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/./Include/internal/pycore_call.h:169:11
    #18 0x60b0de7803dd in method_vectorcall /home/shamil/oss/cpython/main/Objects/classobject.c:95:18
    #19 0x60b0de77692b in _PyVectorcall_Call /home/shamil/oss/cpython/main/Objects/call.c:273:16
    #20 0x60b0dec70b70 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:2616:32
    #21 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #22 0x60b0de77415e in _PyObject_VectorcallDictTstate /home/shamil/oss/cpython/main/Objects/call.c:135:15
    #23 0x60b0de777e2d in _PyObject_Call_Prepend /home/shamil/oss/cpython/main/Objects/call.c:504:24
    #24 0x60b0de9f0fe7 in call_method /home/shamil/oss/cpython/main/Objects/typeobject.c:3076:19
    #25 0x60b0de7746be in _PyObject_MakeTpCall /home/shamil/oss/cpython/main/Objects/call.c:242:18
    #26 0x60b0dec51bd5 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:4021:35
    #27 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #28 0x60b0de784063 in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/./Include/internal/pycore_call.h:169:11
    #29 0x60b0de7803dd in method_vectorcall /home/shamil/oss/cpython/main/Objects/classobject.c:95:18
    #30 0x60b0de77692b in _PyVectorcall_Call /home/shamil/oss/cpython/main/Objects/call.c:273:16
    #31 0x60b0dec70b70 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:2616:32
    #32 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12

Direct leak of 128 byte(s) in 2 object(s) allocated from:
    #0 0x60b0de3a54dd in calloc (/home/shamil/oss/cpython/main/python+0x9b34dd) (BuildId: 37792df6365e32052bfc7119c6be4df8fae85e76)
    #1 0x60b0de96628f in _PyMem_DebugRawAlloc /home/shamil/oss/cpython/main/Objects/obmalloc.c:2884:24
    #2 0x60b0deda055c in _PyXIData_New /home/shamil/oss/cpython/main/Python/crossinterp.c:309:24
    #3 0x6f4afa7ba621 in channel_send /home/shamil/oss/cpython/main/./Modules/_interpchannelsmodule.c:1797:25
    #4 0x6f4afa7b8cd2 in channel_send_wait /home/shamil/oss/cpython/main/./Modules/_interpchannelsmodule.c:1858:15
    #5 0x6f4afa7aef10 in channelsmod_send /home/shamil/oss/cpython/main/./Modules/_interpchannelsmodule.c:3158:15
    #6 0x60b0de8fec4a in cfunction_call /home/shamil/oss/cpython/main/Objects/methodobject.c:564:18
    #7 0x60b0de7746be in _PyObject_MakeTpCall /home/shamil/oss/cpython/main/Objects/call.c:242:18
    #8 0x60b0dec8c537 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:2920:35
    #9 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #10 0x60b0de784063 in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/./Include/internal/pycore_call.h:169:11
    #11 0x60b0de7803dd in method_vectorcall /home/shamil/oss/cpython/main/Objects/classobject.c:95:18
    #12 0x60b0de77692b in _PyVectorcall_Call /home/shamil/oss/cpython/main/Objects/call.c:273:16
    #13 0x60b0dec70b70 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:2616:32
    #14 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #15 0x60b0de77415e in _PyObject_VectorcallDictTstate /home/shamil/oss/cpython/main/Objects/call.c:135:15
    #16 0x60b0de777e2d in _PyObject_Call_Prepend /home/shamil/oss/cpython/main/Objects/call.c:504:24
    #17 0x60b0de9f0fe7 in call_method /home/shamil/oss/cpython/main/Objects/typeobject.c:3076:19
    #18 0x60b0de7746be in _PyObject_MakeTpCall /home/shamil/oss/cpython/main/Objects/call.c:242:18
    #19 0x60b0dec51bd5 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:4021:35
    #20 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #21 0x60b0de784063 in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/./Include/internal/pycore_call.h:169:11
    #22 0x60b0de7803dd in method_vectorcall /home/shamil/oss/cpython/main/Objects/classobject.c:95:18
    #23 0x60b0de77692b in _PyVectorcall_Call /home/shamil/oss/cpython/main/Objects/call.c:273:16
    #24 0x60b0dec70b70 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:2616:32
    #25 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #26 0x60b0de77415e in _PyObject_VectorcallDictTstate /home/shamil/oss/cpython/main/Objects/call.c:135:15
    #27 0x60b0de777e2d in _PyObject_Call_Prepend /home/shamil/oss/cpython/main/Objects/call.c:504:24
    #28 0x60b0de9f0fe7 in call_method /home/shamil/oss/cpython/main/Objects/typeobject.c:3076:19
    #29 0x60b0de7746be in _PyObject_MakeTpCall /home/shamil/oss/cpython/main/Objects/call.c:242:18

Direct leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x60b0de3a54dd in calloc (/home/shamil/oss/cpython/main/python+0x9b34dd) (BuildId: 37792df6365e32052bfc7119c6be4df8fae85e76)
    #1 0x60b0de96628f in _PyMem_DebugRawAlloc /home/shamil/oss/cpython/main/Objects/obmalloc.c:2884:24
    #2 0x60b0deda8d71 in _PyXIData_New /home/shamil/oss/cpython/main/Python/crossinterp.c:309:24
    #3 0x60b0deda8d71 in _sharednsitem_set_value /home/shamil/oss/cpython/main/Python/crossinterp.c:2071:20
    #4 0x60b0deda8d71 in _sharednsitem_copy_from_ns /home/shamil/oss/cpython/main/Python/crossinterp.c:2121:9
    #5 0x60b0deda8d71 in _fill_sharedns /home/shamil/oss/cpython/main/Python/crossinterp.c:2385:13
    #6 0x60b0deda6d7f in _PyXI_Enter /home/shamil/oss/cpython/main/Python/crossinterp.c:2639:17
    #7 0x6f4afa73e4ac in _interpreters_set___main___attrs_impl /home/shamil/oss/cpython/main/./Modules/_interpretersmodule.c:1072:9
    #8 0x6f4afa73e4ac in _interpreters_set___main___attrs /home/shamil/oss/cpython/main/./Modules/clinic/_interpretersmodule.c.h:339:20
    #9 0x60b0de773d6e in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/./Include/internal/pycore_call.h:169:11
    #10 0x60b0dec904bc in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:1620:35
    #11 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #12 0x60b0de784063 in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/./Include/internal/pycore_call.h:169:11
    #13 0x60b0de7803dd in method_vectorcall /home/shamil/oss/cpython/main/Objects/classobject.c:95:18
    #14 0x60b0de77692b in _PyVectorcall_Call /home/shamil/oss/cpython/main/Objects/call.c:273:16
    #15 0x60b0dec70b70 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:2616:32
    #16 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #17 0x60b0de77415e in _PyObject_VectorcallDictTstate /home/shamil/oss/cpython/main/Objects/call.c:135:15
    #18 0x60b0de777e2d in _PyObject_Call_Prepend /home/shamil/oss/cpython/main/Objects/call.c:504:24
    #19 0x60b0de9f0fe7 in call_method /home/shamil/oss/cpython/main/Objects/typeobject.c:3076:19
    #20 0x60b0de7746be in _PyObject_MakeTpCall /home/shamil/oss/cpython/main/Objects/call.c:242:18
    #21 0x60b0dec51bd5 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:4021:35
    #22 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #23 0x60b0de784063 in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/./Include/internal/pycore_call.h:169:11
    #24 0x60b0de7803dd in method_vectorcall /home/shamil/oss/cpython/main/Objects/classobject.c:95:18
    #25 0x60b0de77692b in _PyVectorcall_Call /home/shamil/oss/cpython/main/Objects/call.c:273:16
    #26 0x60b0dec70b70 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:2616:32
    #27 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #28 0x60b0de77415e in _PyObject_VectorcallDictTstate /home/shamil/oss/cpython/main/Objects/call.c:135:15
    #29 0x60b0de777e2d in _PyObject_Call_Prepend /home/shamil/oss/cpython/main/Objects/call.c:504:24
    #30 0x60b0de9f0fe7 in call_method /home/shamil/oss/cpython/main/Objects/typeobject.c:3076:19
    #31 0x60b0de7746be in _PyObject_MakeTpCall /home/shamil/oss/cpython/main/Objects/call.c:242:18
    #32 0x60b0dec51bd5 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:4021:35
    #33 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12

Direct leak of 62 byte(s) in 2 object(s) allocated from:
    #0 0x60b0de3a5308 in malloc (/home/shamil/oss/cpython/main/python+0x9b3308) (BuildId: 37792df6365e32052bfc7119c6be4df8fae85e76)
    #1 0x60b0de966323 in _PyMem_DebugRawAlloc /home/shamil/oss/cpython/main/Objects/obmalloc.c:2887:24
    #2 0x60b0deda6991 in _copy_string_obj_raw /home/shamil/oss/cpython/main/Python/crossinterp.c:1055:20
    #3 0x60b0ded9be6f in _PyXI_InitFailure /home/shamil/oss/cpython/main/Python/crossinterp.c:1814:23
    #4 0x6f4afa740461 in _run_script /home/shamil/oss/cpython/main/./Modules/_interpretersmodule.c
    #5 0x6f4afa740461 in _run_in_interpreter /home/shamil/oss/cpython/main/./Modules/_interpretersmodule.c:690:15
    #6 0x6f4afa73d39d in _interpreters_run_string_impl /home/shamil/oss/cpython/main/./Modules/_interpretersmodule.c:1202:15
    #7 0x6f4afa73d39d in _interpreters_run_string /home/shamil/oss/cpython/main/./Modules/clinic/_interpretersmodule.c.h:531:20
    #8 0x60b0de773d6e in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/./Include/internal/pycore_call.h:169:11
    #9 0x60b0dec904bc in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:1620:35
    #10 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #11 0x60b0de784063 in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/./Include/internal/pycore_call.h:169:11
    #12 0x60b0de7803dd in method_vectorcall /home/shamil/oss/cpython/main/Objects/classobject.c:95:18
    #13 0x60b0de77692b in _PyVectorcall_Call /home/shamil/oss/cpython/main/Objects/call.c:273:16
    #14 0x60b0dec70b70 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:2616:32
    #15 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #16 0x60b0de77415e in _PyObject_VectorcallDictTstate /home/shamil/oss/cpython/main/Objects/call.c:135:15
    #17 0x60b0de777e2d in _PyObject_Call_Prepend /home/shamil/oss/cpython/main/Objects/call.c:504:24
    #18 0x60b0de9f0fe7 in call_method /home/shamil/oss/cpython/main/Objects/typeobject.c:3076:19
    #19 0x60b0de7746be in _PyObject_MakeTpCall /home/shamil/oss/cpython/main/Objects/call.c:242:18
    #20 0x60b0dec51bd5 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:4021:35
    #21 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #22 0x60b0de784063 in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/./Include/internal/pycore_call.h:169:11
    #23 0x60b0de7803dd in method_vectorcall /home/shamil/oss/cpython/main/Objects/classobject.c:95:18
    #24 0x60b0de77692b in _PyVectorcall_Call /home/shamil/oss/cpython/main/Objects/call.c:273:16
    #25 0x60b0dec70b70 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:2616:32
    #26 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #27 0x60b0de77415e in _PyObject_VectorcallDictTstate /home/shamil/oss/cpython/main/Objects/call.c:135:15
    #28 0x60b0de777e2d in _PyObject_Call_Prepend /home/shamil/oss/cpython/main/Objects/call.c:504:24
    #29 0x60b0de9f0fe7 in call_method /home/shamil/oss/cpython/main/Objects/typeobject.c:3076:19
    #30 0x60b0de7746be in _PyObject_MakeTpCall /home/shamil/oss/cpython/main/Objects/call.c:242:18
    #31 0x60b0dec51bd5 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:4021:35

Direct leak of 31 byte(s) in 1 object(s) allocated from:
    #0 0x60b0de3a5308 in malloc (/home/shamil/oss/cpython/main/python+0x9b3308) (BuildId: 37792df6365e32052bfc7119c6be4df8fae85e76)
    #1 0x60b0de966323 in _PyMem_DebugRawAlloc /home/shamil/oss/cpython/main/Objects/obmalloc.c:2887:24
    #2 0x60b0deda6991 in _copy_string_obj_raw /home/shamil/oss/cpython/main/Python/crossinterp.c:1055:20
    #3 0x60b0ded9be6f in _PyXI_InitFailure /home/shamil/oss/cpython/main/Python/crossinterp.c:1814:23
    #4 0x6f4afa740461 in _run_script /home/shamil/oss/cpython/main/./Modules/_interpretersmodule.c
    #5 0x6f4afa740461 in _run_in_interpreter /home/shamil/oss/cpython/main/./Modules/_interpretersmodule.c:690:15
    #6 0x6f4afa73d39d in _interpreters_run_string_impl /home/shamil/oss/cpython/main/./Modules/_interpretersmodule.c:1202:15
    #7 0x6f4afa73d39d in _interpreters_run_string /home/shamil/oss/cpython/main/./Modules/clinic/_interpretersmodule.c.h:531:20
    #8 0x60b0dec6bbcf in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:2361:35
    #9 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #10 0x60b0de784063 in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/./Include/internal/pycore_call.h:169:11
    #11 0x60b0de7803dd in method_vectorcall /home/shamil/oss/cpython/main/Objects/classobject.c:95:18
    #12 0x60b0de77692b in _PyVectorcall_Call /home/shamil/oss/cpython/main/Objects/call.c:273:16
    #13 0x60b0dec70b70 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:2616:32
    #14 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #15 0x60b0de77415e in _PyObject_VectorcallDictTstate /home/shamil/oss/cpython/main/Objects/call.c:135:15
    #16 0x60b0de777e2d in _PyObject_Call_Prepend /home/shamil/oss/cpython/main/Objects/call.c:504:24
    #17 0x60b0de9f0fe7 in call_method /home/shamil/oss/cpython/main/Objects/typeobject.c:3076:19
    #18 0x60b0de7746be in _PyObject_MakeTpCall /home/shamil/oss/cpython/main/Objects/call.c:242:18
    #19 0x60b0dec51bd5 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:4021:35
    #20 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #21 0x60b0de784063 in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/./Include/internal/pycore_call.h:169:11
    #22 0x60b0de7803dd in method_vectorcall /home/shamil/oss/cpython/main/Objects/classobject.c:95:18
    #23 0x60b0de77692b in _PyVectorcall_Call /home/shamil/oss/cpython/main/Objects/call.c:273:16
    #24 0x60b0dec70b70 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:2616:32
    #25 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12
    #26 0x60b0de77415e in _PyObject_VectorcallDictTstate /home/shamil/oss/cpython/main/Objects/call.c:135:15
    #27 0x60b0de777e2d in _PyObject_Call_Prepend /home/shamil/oss/cpython/main/Objects/call.c:504:24
    #28 0x60b0de9f0fe7 in call_method /home/shamil/oss/cpython/main/Objects/typeobject.c:3076:19
    #29 0x60b0de7746be in _PyObject_MakeTpCall /home/shamil/oss/cpython/main/Objects/call.c:242:18
    #30 0x60b0dec51bd5 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:4021:35
    #31 0x60b0dec3c6b1 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2001:12

SUMMARY: AddressSanitizer: 1565 byte(s) leaked in 26 allocation(s).

== Tests result: FAILURE ==

1 test failed:
    test__interpchannels

Total duration: 3.2 sec
Total tests: run=0
Total test files: run=1/1 failed=1
Result: FAILURE
[0 refs, 0 blocks]

After

Using random seed: 1634876683
0:00:00 load avg: 6.85 Run 1 test in parallel using 1 worker process
0:00:03 load avg: 6.54 [1/1] test__interpchannels passed
[0 refs, 0 blocks]

== Tests result: SUCCESS ==

1 test OK.

Total duration: 3.6 sec
Total tests: run=70 skipped=5
Total test files: run=1/1
Result: SUCCESS
[0 refs, 0 blocks]

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@efimov-mikhail

efimov-mikhail commented Oct 18, 2025

Copy link
Copy Markdown
Member

I've also found similar bug in Modules/_interpqueuesmodule.c. Expression XID_IGNORE_EXC & XID_FREE is used there.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ashm-dev

ashm-dev commented Oct 18, 2025

Copy link
Copy Markdown
Contributor Author

I've also found similar bug in Modules/_interpqueuesmodule.c. Expression XID_IGNORE_EXC & XID_FREE is used there.

Each variant needs to be carefully checked there, because some are correct and some aren't. I didn't look at the others because there were no leaks there :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@efimov-mikhail

efimov-mikhail commented Oct 18, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I think there're leaks there, you can find them with test.test_interpreters.

But we can fix them in a separate PR.
Those 3 fixes which is already here LGTM.

ashm-dev reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ashm-dev
Fix bitwise operation in _queueitem_clear_data
2eca13c
efimov-mikhail
efimov-mikhail approved these changes Oct 18, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting core review and removed awaiting review labels Oct 18, 2025
@efimov-mikhail
efimov-mikhail requested a review from serhiy-storchaka October 18, 2025 22:27
serhiy-storchaka
serhiy-storchaka reviewed Oct 19, 2025
View reviewed changes
Comment thread Python/crossinterp.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Misc/NEWS.d/next/Core_and_Builtins/2025-10-18-21-29-45.gh-issue-140306.xS5CcS.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka

serhiy-storchaka commented Oct 19, 2025

Copy link
Copy Markdown
Member

XID_IGNORE_EXC & XID_FREE is never correct. It is simply 0.

efimov-mikhail and ashm-dev reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ashm-dev added 2 commits October 19, 2025 12:34
@ashm-dev
add period
f67f251
@ashm-dev
fix
f885523
@ashm-dev
ashm-dev requested a review from serhiy-storchaka October 19, 2025 10:21
serhiy-storchaka
serhiy-storchaka reviewed Oct 19, 2025
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And please fix all other occurrences of XID_IGNORE_EXC & XID_FREE if there are any.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Python/crossinterp.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ashm-dev @serhiy-storchaka
Update Python/crossinterp.c
ea1546b
Co-authored-by: Serhiy Storchaka <[email protected]>
@ashm-dev

ashm-dev commented Oct 19, 2025

Copy link
Copy Markdown
Contributor Author

And please fix all other occurrences of XID_IGNORE_EXC & XID_FREE if there are any.

There are no more such places in the code.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ashm-dev
ashm-dev requested a review from serhiy-storchaka October 19, 2025 11:21
serhiy-storchaka
serhiy-storchaka approved these changes Oct 19, 2025
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ashm-dev reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Oct 19, 2025
@serhiy-storchaka
serhiy-storchaka merged commit f932321 into python:main Oct 19, 2025
4 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Oct 19, 2025
@ashm-dev
ashm-dev deleted the test__interpchannels_leak branch October 19, 2025 19:24
@serhiy-storchaka serhiy-storchaka added the needs backport to 3.14 bugs and security fixes label Oct 19, 2025
@miss-islington-app

miss-islington-app Bot commented Oct 19, 2025

Copy link
Copy Markdown

Thanks @ashm-dev for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 19, 2025
@ashm-dev @miss-islington
pythongh-140306: Fix memory leaks in cross-interpreter data handling (p…
5de8a01
…ythonGH-140307)

(cherry picked from commit f932321)

Co-authored-by: Shamil <[email protected]>
@bedevere-app

bedevere-app Bot commented Oct 19, 2025

Copy link
Copy Markdown

GH-140338 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 19, 2025
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels Oct 19, 2025
@miss-islington-app

miss-islington-app Bot commented Oct 19, 2025

Copy link
Copy Markdown

Thanks @ashm-dev for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app

miss-islington-app Bot commented Oct 19, 2025

Copy link
Copy Markdown

Thanks @ashm-dev for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app

miss-islington-app Bot commented Oct 19, 2025

Copy link
Copy Markdown

Sorry, @ashm-dev and @serhiy-storchaka, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker f9323213c98c9f1f7f3bf5af883b73047432fe50 3.13
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app miss-islington-app Bot assigned serhiy-storchaka Oct 19, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 19, 2025
@ashm-dev @miss-islington
pythongh-140306: Fix memory leaks in cross-interpreter data handling (p…
ffe37c9
…ythonGH-140307)

(cherry picked from commit f932321)

Co-authored-by: Shamil <[email protected]>
@miss-islington-app

miss-islington-app Bot commented Oct 19, 2025

Copy link
Copy Markdown

Sorry @ashm-dev and @serhiy-storchaka, I had trouble completing the backport.
Please retry by removing and re-adding the "needs backport to 3.14" label.
Please backport backport using cherry_picker on the command line.

cherry_picker f9323213c98c9f1f7f3bf5af883b73047432fe50 3.14
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka pushed a commit that referenced this pull request Oct 19, 2025
@miss-islington @ashm-dev
[3.14] gh-140306: Fix memory leaks in cross-interpreter data handling (…
6cee144
…GH-140307) (GH-140338)

(cherry picked from commit f932321)

Co-authored-by: Shamil <[email protected]>
@serhiy-storchaka serhiy-storchaka removed needs backport to 3.14 bugs and security fixes needs backport to 3.13 only security fixes labels Oct 20, 2025
serhiy-storchaka pushed a commit to serhiy-storchaka/cpython that referenced this pull request Oct 20, 2025
@ashm-dev @serhiy-storchaka
[3.13] pythongh-140306: Fix memory leaks in cross-interpreter data ha…
45853b9
…ndling (pythonGH-140307)

(cherry picked from commit f932321)

Co-authored-by: Shamil <[email protected]>
@bedevere-app

bedevere-app Bot commented Oct 20, 2025

Copy link
Copy Markdown

GH-140357 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka pushed a commit to serhiy-storchaka/cpython that referenced this pull request Oct 20, 2025
@ashm-dev @serhiy-storchaka
[3.13] pythongh-140306: Fix memory leaks in cross-interpreter data ha…
1977465
…ndling (pythonGH-140307)

(cherry picked from commit f932321)

Co-authored-by: Shamil <[email protected]>
serhiy-storchaka pushed a commit to serhiy-storchaka/cpython that referenced this pull request Oct 20, 2025
@ashm-dev @serhiy-storchaka
[3.13] pythongh-140306: Fix memory leaks in cross-interpreter data ha…
10d578f
…ndling (pythonGH-140307)

(cherry picked from commit f932321)

Co-authored-by: Shamil <[email protected]>
serhiy-storchaka added a commit that referenced this pull request Oct 20, 2025
@serhiy-storchaka @ashm-dev
[3.13] gh-140306: Fix memory leaks in cross-interpreter data handling (…
d7473f7
…GH-140307) (GH-140357)

(cherry picked from commit f932321)

Co-authored-by: Shamil <[email protected]>
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
@ashm-dev @StanFromIreland
pythongh-140306: Fix memory leaks in cross-interpreter data handling (p…
1e1d227
…ythonGH-140307)
@serhiy-storchaka serhiy-storchaka removed their assignment Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes
@efimov-mikhail efimov-mikhail efimov-mikhail approved these changes
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@ashm-dev @efimov-mikhail @serhiy-storchaka
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.