Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on _PyTuple_Fini for code using sub interpreters #112140

Closed
tonybaloney opened this issue Nov 16, 2023 · 2 comments
Closed

Crash on _PyTuple_Fini for code using sub interpreters #112140

tonybaloney opened this issue Nov 16, 2023 · 2 comments
Labels
topic-subinterpreters type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@tonybaloney
Copy link
Contributor

tonybaloney commented Nov 16, 2023

Crash report

What happened?

In certain cases, the finalization stage of CPython is crashing when free'ing the PyTuple Free lists (see stack trace).

One such example I can consistently reproduce is this import (pip install hypercorn)

import _xxsubinterpreters as interpreters

i = interpreters.create()
interpreters.run_string(i, "from hypercorn.asyncio.run import asyncio_worker")

Output:

Debug memory block at address p=0x10e8393b0: API '�'
    15987178197214944733 bytes originally requested
    The 7 pad bytes at p-7 are not all FORBIDDENBYTE (0xfd):
        at p-7: 0xdd *** OUCH
        at p-6: 0xdd *** OUCH
        at p-5: 0xdd *** OUCH
        at p-4: 0xdd *** OUCH
        at p-3: 0xdd *** OUCH
        at p-2: 0xdd *** OUCH
        at p-1: 0xdd *** OUCH
    Because memory is corrupted at the start, the count of bytes requested
       may be bogus, and checking the trailing pad bytes may segfault.
    The 8 pad bytes at tail=0xdddddddeec61718d are zsh: segmentation fault  python test_hypercorn.py

Stack trace:

python!_PyObject_DebugDumpAddress (/Users/anthonyshaw/projects/cpython/Objects/obmalloc.c:2578)
python!_PyMem_DebugCheckAddress (/Users/anthonyshaw/projects/cpython/Objects/obmalloc.c:2496)
python!_PyMem_DebugRawFree (/Users/anthonyshaw/projects/cpython/Objects/obmalloc.c:2329)
python!PyMem_RawFree (/Users/anthonyshaw/projects/cpython/Objects/obmalloc.c:818)
python!_PyObject_Free (/Users/anthonyshaw/projects/cpython/Objects/obmalloc.c:2023)
python!_PyMem_DebugRawFree (/Users/anthonyshaw/projects/cpython/Objects/obmalloc.c:2333)
python!_PyMem_DebugFree (/Users/anthonyshaw/projects/cpython/Objects/obmalloc.c:2466)
python!PyObject_Free (/Users/anthonyshaw/projects/cpython/Objects/obmalloc.c:963)
python!PyObject_GC_Del (/Users/anthonyshaw/projects/cpython/Modules/gcmodule.c:2414)
python!maybe_freelist_clear (/Users/anthonyshaw/projects/cpython/Objects/tupleobject.c:1209)
python!_PyTuple_Fini (/Users/anthonyshaw/projects/cpython/Objects/tupleobject.c:970)
python!finalize_interp_types (/Users/anthonyshaw/projects/cpython/Python/pylifecycle.c:1764)
python!finalize_interp_clear (/Users/anthonyshaw/projects/cpython/Python/pylifecycle.c:1802)
python!Py_FinalizeEx (/Users/anthonyshaw/projects/cpython/Python/pylifecycle.c:2013)
python!Py_RunMain (/Users/anthonyshaw/projects/cpython/Modules/main.c:709)
python!pymain_main (/Users/anthonyshaw/projects/cpython/Modules/main.c:737)
python!Py_BytesMain (/Users/anthonyshaw/projects/cpython/Modules/main.c:761)
python!main (/Users/anthonyshaw/projects/cpython/Programs/python.c:15)
start (Unknown Source:0)

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Output from running 'python -VV' on the command line:

Python 3.13.0a1+ (heads/main:55f3cce821, Nov 15 2023, 14:40:56) [Clang 14.0.3 (clang-1403.0.22.14.1)]

@ericsnowcurrently
Copy link
Member

@tonybaloney, is this still a problem? I just tried it on main and did not get a crash.

@tonybaloney
Copy link
Contributor Author

I haven't seen this crash for a long time, so closing

@github-project-automation github-project-automation bot moved this from Todo to Done in Subinterpreters Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-subinterpreters type-crash A hard crash of the interpreter, possibly with a core dump
Projects
Status: Done
Development

No branches or pull requests

3 participants