Skip to content

ASan memory leak in test_gc with --enable-experimental-jit (allocate_executor) #142476

@ashm-dev

Description

@ashm-dev

Bug report

Bug description:

I encountered a memory leak detection by AddressSanitizer when running test_gc with the experimental JIT enabled.

Build reproduction

CC=clang-21 CXX=clang++-21 ./configure --with-pydebug --with-address-sanitizer --enable-experimental-jit=yes && make -j

Test execution

./python -X dev -m test test_gc -j8 -uall

Output

Using random seed: 3252749262
0:00:00 load avg: 27.26 Run 1 test in parallel using 1 worker process
0:00:07 load avg: 23.30 [1/1/1] test_gc failed (1 failure)
test test_gc failed -- Traceback (most recent call last):
  File "/home/shamil/oss/cpython/main/Lib/test/test_gc.py", line 1242, in test_incremental_gc_handles_fast_cycle_creation
    run_test_script(script)
    ~~~~~~~~~~~~~~~^^^^^^^^
  File "/home/shamil/oss/cpython/main/Lib/test/support/script_helper.py", line 324, in run_test_script
    assert_python_ok("-u", script, "-v")
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/home/shamil/oss/cpython/main/Lib/test/support/script_helper.py", line 182, in assert_python_ok
    return _assert_python(True, *args, **env_vars)
  File "/home/shamil/oss/cpython/main/Lib/test/support/script_helper.py", line 167, in _assert_python
    res.fail(cmd_line)
    ~~~~~~~~^^^^^^^^^^
  File "/home/shamil/oss/cpython/main/Lib/test/support/script_helper.py", line 80, in fail
    raise AssertionError(f"Process return code is {exitcode}\n"
    ...<10 lines>...
                         f"---")
AssertionError: Process return code is 1
command line: ['/home/shamil/oss/cpython/main/python', '-X', 'faulthandler', '-I', '-u', '/home/shamil/oss/cpython/main/Lib/test/_test_gc_fast_cycles.py', '-v']

stdout:
---

---

stderr:
---
test_incremental_gc_handles_fast_cycle_creation (__main__.IncrementalGCTests.test_incremental_gc_handles_fast_cycle_creation) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.412s

OK

=================================================================
==16076==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 2280 byte(s) in 1 object(s) allocated from:
    #0 0x60e720cbba98 in malloc (/home/shamil/oss/cpython/main/python+0x360a98) (BuildId: 36b2d572cb504336bfe93807eea32cad15efa807)
    #1 0x60e72102e761 in _PyMem_DebugRawAlloc /home/shamil/oss/cpython/main/Objects/obmalloc.c:2889:24
    #2 0x60e72102e761 in _PyMem_DebugRawMalloc /home/shamil/oss/cpython/main/Objects/obmalloc.c:2922:12
    #3 0x60e72102e761 in _PyMem_DebugMalloc /home/shamil/oss/cpython/main/Objects/obmalloc.c:3087:12
    #4 0x60e7213573b0 in _PyObject_MallocWithType /home/shamil/oss/cpython/main/./Include/internal/pycore_object_alloc.h:46:17
    #5 0x60e7213573b0 in gc_alloc /home/shamil/oss/cpython/main/Python/gc.c:2352:17
    #6 0x60e7213573b0 in _PyObject_GC_NewVar /home/shamil/oss/cpython/main/Python/gc.c:2394:25
    #7 0x60e7214d102e in allocate_executor /home/shamil/oss/cpython/main/Python/optimizer.c:1176:30
    #8 0x60e7214d102e in make_executor_from_uops /home/shamil/oss/cpython/main/Python/optimizer.c:1260:35
    #9 0x60e7214d102e in uop_optimize /home/shamil/oss/cpython/main/Python/optimizer.c:1397:35
    #10 0x60e7214d102e in _PyOptimizer_Optimize /home/shamil/oss/cpython/main/Python/optimizer.c:164:15
    #11 0x60e7212b79c3 in stop_tracing_and_jit /home/shamil/oss/cpython/main/Python/ceval.c:1392:15
    #12 0x60e721275f41 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:11383:27
    #13 0x60e7212516a7 in _PyEval_EvalFrame /home/shamil/oss/cpython/main/./Include/internal/pycore_ceval.h:119:16
    #14 0x60e7212516a7 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2453:12
    #15 0x60e720ece23f in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/./Include/internal/pycore_call.h:136:11
    #16 0x60e720ecb686 in method_vectorcall /home/shamil/oss/cpython/main/Objects/classobject.c:95:18
    #17 0x60e720ec3ee9 in _PyVectorcall_Call /home/shamil/oss/cpython/main/Objects/call.c:273:16
    #18 0x60e72127c64d in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:2450:32
    #19 0x60e7212516a7 in _PyEval_EvalFrame /home/shamil/oss/cpython/main/./Include/internal/pycore_ceval.h:119:16
    #20 0x60e7212516a7 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2453:12
    #21 0x60e720ec1c11 in _PyObject_VectorcallDictTstate /home/shamil/oss/cpython/main/Objects/call.c:135:15
    #22 0x60e720ec4ea5 in _PyObject_Call_Prepend /home/shamil/oss/cpython/main/Objects/call.c:504:24
    #23 0x60e7210937a2 in call_method /home/shamil/oss/cpython/main/Objects/typeobject.c:3087:19
    #24 0x60e720ec221a in _PyObject_MakeTpCall /home/shamil/oss/cpython/main/Objects/call.c:242:18
    #25 0x60e721251c10 in _Py_VectorCall_StackRefSteal /home/shamil/oss/cpython/main/Python/ceval.c:1042:11
    #26 0x60e721276ddf in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:3704:35
    #27 0x60e7212516a7 in _PyEval_EvalFrame /home/shamil/oss/cpython/main/./Include/internal/pycore_ceval.h:119:16
    #28 0x60e7212516a7 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2453:12
    #29 0x60e720ece23f in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/./Include/internal/pycore_call.h:136:11
    #30 0x60e720ecb686 in method_vectorcall /home/shamil/oss/cpython/main/Objects/classobject.c:95:18
    #31 0x60e720ec3ee9 in _PyVectorcall_Call /home/shamil/oss/cpython/main/Objects/call.c:273:16
    #32 0x60e72127c64d in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:2450:32
    #33 0x60e7212516a7 in _PyEval_EvalFrame /home/shamil/oss/cpython/main/./Include/internal/pycore_ceval.h:119:16
    #34 0x60e7212516a7 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2453:12
    #35 0x60e720ec1c11 in _PyObject_VectorcallDictTstate /home/shamil/oss/cpython/main/Objects/call.c:135:15
    #36 0x60e720ec4ea5 in _PyObject_Call_Prepend /home/shamil/oss/cpython/main/Objects/call.c:504:24
    #37 0x60e7210937a2 in call_method /home/shamil/oss/cpython/main/Objects/typeobject.c:3087:19
    #38 0x60e720ec221a in _PyObject_MakeTpCall /home/shamil/oss/cpython/main/Objects/call.c:242:18
    #39 0x60e72128d4ff in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/Python/generated_cases.c.h:1574:35
    #40 0x60e7212516a7 in _PyEval_EvalFrame /home/shamil/oss/cpython/main/./Include/internal/pycore_ceval.h:119:16
    #41 0x60e7212516a7 in _PyEval_Vector /home/shamil/oss/cpython/main/Python/ceval.c:2453:12

SUMMARY: AddressSanitizer: 2280 byte(s) leaked in 1 allocation(s).

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)topic-JITtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions