| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1413,6 +1413,21 @@ def handler(a, b): | |||
| 1413 | 1413 | signal.raise_signal(signal.SIGINT) | |
| 1414 | 1414 | self.assertTrue(is_ok) | |
| 1415 | 1415 | ||
| 1416 | + def test__thread_interrupt_main(self): | ||
| 1417 | + # See https://github.com/python/cpython/issues/102397 | ||
| 1418 | + code = """if 1: | ||
| 1419 | + import _thread | ||
| 1420 | + class Foo(): | ||
| 1421 | + def __del__(self): | ||
| 1422 | + _thread.interrupt_main() | ||
| 1423 | + | ||
| 1424 | + x = Foo() | ||
| 1425 | + """ | ||
| 1426 | + | ||
| 1427 | + rc, out, err = assert_python_ok('-c', code) | ||
| 1428 | + self.assertIn(b'OSError: Signal 2 ignored due to race condition', err) | ||
| 1429 | + | ||
| 1430 | + | ||
| 1416 | 1431 | ||
| 1417 | 1432 | class PidfdSignalTest(unittest.TestCase): | |
| 1418 | 1433 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + Fix segfault from race condition in signal handling during garbage collection. | ||
| 2 | + Patch by Kumar Aditya. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -181,6 +181,10 @@ get_signal_state(PyObject *module) | |||
| 181 | 181 | static inline int | |
| 182 | 182 | compare_handler(PyObject *func, PyObject *dfl_ign_handler) | |
| 183 | 183 | { | |
| 184 | + // See https://github.com/python/cpython/pull/102399 | ||
| 185 | + if (func == NULL || dfl_ign_handler == NULL) { | ||
| 186 | + return 0; | ||
| 187 | + } | ||
| 184 | 188 | assert(PyLong_CheckExact(dfl_ign_handler)); | |
| 185 | 189 | if (!PyLong_CheckExact(func)) { | |
| 186 | 190 | return 0; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments