pylifecycle.c: Multiple init/fini cleanup bugs
Open
Nobody has claimed this yet.
interpreter-core
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
Parent: https://github.com/python/cpython/issues/146102
https://gist.github.com/devdanzin/b022ff2d1304a4b2b8d3d8750abd8da5
pylifecycle.c: Multiple init/fini cleanup bugs
Summary
5 bugs in interpreter lifecycle:
- new_interpreter (line 2534):
return statusbypasses switch-back aftersave_tstatedetach → thread state corruption. - pycore_init_builtins (line 860): Direct
returnleaksbimodref. - add_main_module (line 2762):
bimod/loaderrefs leaked onPyDict_SetItemStringfailure. - finalize_clear_modules_dict (line 1685): Return value of
PyObject_CallMethodNoArgsnever DECREF'd. - init_sys_streams (line 3019-3031): Unchecked
PySys_SetObjectfor stdin/stdout (stderr correctly checked).
CPython versions tested on:
CPython main branch, 3.15
Operating systems tested on:
No response
Linked PRs
- gh-149631
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the parent issue and linked gist, then inspect pylifecycle.c at new_interpreter, pycore_init_builtins, add_main_module, finalize_clear_modules_dict, and init_sys_streams. Check each reported failure path and use the linked PR gh-149631 for existing context. Done means all five lifecycle cleanup issues are addressed without introducing new reference or thread-state problems.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100