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)
Guess I found a minimal reproducer:
import _thread class Foo(): def __del__(self): _thread.interrupt_main() x = Foo()
This, as well as original one, crashes on 3.10.8, 3.11.0 and current main under Linux.
Yeah, both of these crashes are basically the same, they both crash in compare_handler in 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…
[3.10] GH-102397: Fix segfault from race condition in signal handling (…
GH-102397: Fix segfault from race condition in signal handling (GH-10…
Fixed in main and backported, closing.
Merge branch 'main' into inlinecomp2
Activity
chgnrdv commented on 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 commented on Mar 3, 2023
Yeah, both of these crashes are basically the same, they both crash in compare_handler in 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 commented on Mar 8, 2023
Fixed in main and backported, closing.
Merge branch 'main' into inlinecomp2