homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients JelleZijlstra, benjamin.peterson, corona10, remi.lapeyre, serhiy.storchaka, stutzbach, vstinner
Date 2020年06月01日.15:36:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1591025787.65.0.719628555886.issue40826@roundup.psfhosted.org>
In-reply-to
Content
So PyOS_InterruptOccurred() must be called with the GIL held since 3.8, it's just that the nobody noticed the bug before.
If SIGGINT is tripped and the GIL is released, PyOS_InterruptOccurred() does also crash in Python 3.8.
--
One way to see the bug in Python 3.8 without having to trip SIGINT.
Apply this patch:
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index 0c9a2671fe..b850af3163 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -1729,11 +1729,12 @@ PyOS_FiniInterrupts(void)
 int
 PyOS_InterruptOccurred(void)
 {
+ _PyRuntimeState *runtime = &_PyRuntime;
+ if (!is_main(runtime)) {
+ return 0;
+ }
+
 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;
 }
$ make
$ find -name "*readline*so" -delete
$ ./python
Python 3.8.3+ (heads/3.8-dirty:00a240bf7f, Jun 1 2020, 17:24:09) 
[GCC 10.1.1 20200507 (Red Hat 10.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os; os.close(0)
>>>
Erreur de segmentation (core dumped)
---
Reproduce the bug in Python 3.8 without modifying the code, using gdb to trigger events SIGINT at the right place:
$ gdb ./python
(gdb) b my_fgets
Breakpoint 1 at 0x68b941: file Parser/myreadline.c, line 39.
(gdb) run
Python 3.8.3+ (heads/3.8:00a240bf7f, Jun 1 2020, 17:27:24) 
[GCC 10.1.1 20200507 (Red Hat 10.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
Breakpoint 1, my_fgets (...)
(gdb) p (void)close(0)
(gdb) delete 1
(gdb) signal SIGINT
Continuing with signal SIGINT.
Program received signal SIGSEGV, Segmentation fault.
is_main (runtime=0x7ff6c0 <_PyRuntime>) at ./Modules/signalmodule.c:193
193	 PyInterpreterState *interp = _PyRuntimeState_GetThreadState(runtime)->interp;
History
Date User Action Args
2020年06月01日 15:36:27vstinnersetrecipients: + vstinner, benjamin.peterson, stutzbach, serhiy.storchaka, JelleZijlstra, corona10, remi.lapeyre
2020年06月01日 15:36:27vstinnersetmessageid: <1591025787.65.0.719628555886.issue40826@roundup.psfhosted.org>
2020年06月01日 15:36:27vstinnerlinkissue40826 messages
2020年06月01日 15:36:27vstinnercreate

AltStyle によって変換されたページ (->オリジナル) /