Repository navigation
Closed
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Description
The following code segfaults the interpreter on Linux. Tested on current main.
import gc
import _thread
gc.set_threshold(1, 0, 0)
def cb(*args):
_thread.interrupt_main()
gc.callbacks.append(cb)
def gen():
yield 1
g = gen()
g.__next__()Exception ignored in: <function cb at 0x7f7f4f6fe200>
Traceback (most recent call last):
File "/workspaces/cpython/main.py", line 7, in cb
_thread.interrupt_main()
KeyboardInterrupt:
Exception ignored in: <function cb at 0x7f7f4f6fe200>
Traceback (most recent call last):
File "/workspaces/cpython/main.py", line 7, in cb
_thread.interrupt_main()
KeyboardInterrupt:
Exception ignored in: <function cb at 0x7f7f4f6fe200>
Traceback (most recent call last):
File "/workspaces/cpython/main.py", line 7, in cb
_thread.interrupt_main()
KeyboardInterrupt:
Exception ignored in: <function cb at 0x7f7f4f6fe200>
Traceback (most recent call last):
File "/workspaces/cpython/main.py", line 7, in cb
_thread.interrupt_main()
KeyboardInterrupt:
Segmentation fault (core dumped)Linked PRs
Metadata
Metadata
Assignees
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Activity
chgnrdv commentedon Mar 3, 2023
Guess I found a minimal reproducer:
This, as well as original one, crashes on 3.10.8, 3.11.0 and current main under Linux.
kumaraditya303 commentedon Mar 3, 2023
Yeah, both of these crashes are basically the same, they both crash in
compare_handlerin signal handling, I am working on a fix.GH-102397: Fix segfault from race condition in signal handling (#102399)
pythonGH-102397: Fix segfault from race condition in signal handling (p…
pythonGH-102397: Fix segfault from race condition in signal handling (p…
[3.10] GH-102397: Fix segfault from race condition in signal handling (…
GH-102397: Fix segfault from race condition in signal handling (GH-10…
kumaraditya303 commentedon Mar 8, 2023
Fixed in main and backported, closing.
Merge branch 'main' into inlinecomp2