_PyInterpreterState_DeleteExceptMain() May Cause Problems During Fork
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- operating-systems
Research direction
Start in Python/pystate.c around lines 930-932 and trace PyInterpreterState_DeleteExceptMain() as called by PyOS_AfterFork_Child(). Reproduce or investigate the suspected failure with test__xxsubinterpreters and the test_multiprocessing* tests. Done means fork with multiple interpreters no longer causes the reported crash or intermittent failures, with regression coverage if the behavior is confirmed.
Written by the indexing model from the issue text.
Description
_PyInterpreterState_DeleteExceptMain() first sets the "current" thread state to NULL (while still holding the GIL) but then calls PyInterpreterState_Clear() on any other interpreter, even though it depends on there being a "current" thread set. I would expect this to cause crashes when a process with multiple interpreters if forked, since PyOS_AfterFork_Child() calls _PyInterpreterState_DeleteExceptMain(). This might explain some intermittent CI failures (e.g. with test__xxsubinterpreters or test_multiprocessing_*)
See https://github.com/python/cpython/blob/main/Python/pystate.c#L930-L932.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 558
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.
More from python/cpython
-
docs pending
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
stdlib type-feature
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
stdlib type-feature
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
build type-bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
stdlib topic-email type-feature
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
OpenHands/extensions#626 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
CSCfi/sd-search-api#39 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
StevenBlack/hosts#3255 ·