Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1a84cc0

Browse files
GH-102397: Fix segfault from race condition in signal handling (#102399)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
1 parent061325e commit1a84cc0

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

‎Lib/test/test_signal.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,21 @@ def handler(a, b):
14061406
signal.raise_signal(signal.SIGINT)
14071407
self.assertTrue(is_ok)
14081408

1409+
deftest__thread_interrupt_main(self):
1410+
# See https://github.com/python/cpython/issues/102397
1411+
code="""if 1:
1412+
import _thread
1413+
class Foo():
1414+
def __del__(self):
1415+
_thread.interrupt_main()
1416+
1417+
x = Foo()
1418+
"""
1419+
1420+
rc,out,err=assert_python_ok('-c',code)
1421+
self.assertIn(b'OSError: Signal 2 ignored due to race condition',err)
1422+
1423+
14091424

14101425
classPidfdSignalTest(unittest.TestCase):
14111426

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix segfault from race condition in signal handling during garbage collection.
2+
Patch by Kumar Aditya.

‎Modules/signalmodule.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ get_signal_state(PyObject *module)
148148
staticinlineint
149149
compare_handler(PyObject*func,PyObject*dfl_ign_handler)
150150
{
151+
// See https://github.com/python/cpython/pull/102399
152+
if (func==NULL||dfl_ign_handler==NULL) {
153+
return0;
154+
}
151155
assert(PyLong_CheckExact(dfl_ign_handler));
152156
if (!PyLong_CheckExact(func)) {
153157
return0;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp