Message370553
I can reproduce PyOS_InterruptOccurred() crash in Python 3.8 if I remove readline.cpython-38d-x86_64-linux-gnu.so and I disable EINTR error checking in my_fgets():
diff --git a/Parser/myreadline.c b/Parser/myreadline.c
index 43e5583b8b..2712dedacd 100644
--- a/Parser/myreadline.c
+++ b/Parser/myreadline.c
@@ -73,7 +73,7 @@ my_fgets(char *buf, int len, FILE *fp)
clearerr(fp);
return -1; /* EOF */
}
-#ifdef EINTR
+#if 0
if (err == EINTR) {
int s;
PyEval_RestoreThread(_PyOS_ReadlineTState);
vstinner@apu$ ./python
Python 3.8.3+ (heads/3.8-dirty:00a240bf7f, Jun 1 2020, 17:00:22)
[GCC 10.1.1 20200507 (Red Hat 10.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
^C
Erreur de segmentation (core dumped)
I cannot reproduce the issue in Python 3.7.
---
Python 3.7:
---
int
PyOS_InterruptOccurred(void)
{
if (_Py_atomic_load_relaxed(&Handlers[SIGINT].tripped)) {
if (PyThread_get_thread_ident() != main_thread)
return 0;
_Py_atomic_store_relaxed(&Handlers[SIGINT].tripped, 0);
return 1;
}
return 0;
}
---
Python 3.8:
---
static int
is_main(_PyRuntimeState *runtime)
{
unsigned long thread = PyThread_get_thread_ident();
PyInterpreterState *interp = _PyRuntimeState_GetThreadState(runtime)->interp;
return (thread == runtime->main_thread
&& interp == runtime->interpreters.main);
}
int
PyOS_InterruptOccurred(void)
{
if (_Py_atomic_load_relaxed(&Handlers[SIGINT].tripped)) {
_PyRuntimeState *runtime = &_PyRuntime;
if (!is_main(runtime)) {
return 0;
}
_Py_atomic_store_relaxed(&Handlers[SIGINT].tripped, 0);
return 1;
}
return 0;
}
---
is_main() function was added in Python 3.8 by:
commit 64d6cc826dacebc2493b1bb5e8cb97828eb76f81
Author: Eric Snow <ericsnowcurrently@gmail.com>
Date: Sat Feb 23 15:40:43 2019 -0700
bpo-35724: Explicitly require the main interpreter for signal-handling. (GH-11530)
Ensure that the main interpreter is active (in the main thread) for signal-handling operations. This is increasingly relevant as people use subinterpreters more.
https://bugs.python.org/issue35724 |
|
Date |
User |
Action |
Args |
2020-06-01 15:03:02 | vstinner | set | recipients:
+ vstinner, benjamin.peterson, stutzbach, serhiy.storchaka, JelleZijlstra, corona10, remi.lapeyre |
2020-06-01 15:03:02 | vstinner | set | messageid: <1591023782.28.0.804513208825.issue40826@roundup.psfhosted.org> |
2020-06-01 15:03:02 | vstinner | link | issue40826 messages |
2020-06-01 15:03:02 | vstinner | create | |
|