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.

classification
Title: intcatcher() can deadlock
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, hfuru, iritkatriel, vstinner
Priority: normal Keywords: patch

Created on 2010-11-04 12:49 by hfuru, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
intrcheck.diff hfuru, 2010-11-04 12:49 intcatcher() fixes
Messages (5)
msg120399 - (view) Author: Hallvard B Furuseth (hfuru) Date: 2010-11-04 12:49
Parser/intrcheck.c:intcatcher() can do FILE* operations, which can
deadlock if the interrupt happens while a FILE* operation on the same
FILE holds a mutex for the FILE.  I've seen this happen elsewhere.

It'd rather be a pity to remove Py_Exit(), so I suggest
switch(interrupted++) gets a case 3 or 4: which does _exit(1),
and 'interrupted = 0;' is moved there from case 2.

Also 'interrupted' should be volatile sig_atomic_t, and
the function should save/restore errno as in Issue 10311.

BTW, you could use strlen(message) instead of sizeof(message)-1.
msg120845 - (view) Author: Hallvard B Furuseth (hfuru) Date: 2010-11-09 08:42
Sorry, my patch is useless if the OS calls the handler with the signal
blocked.  It should also unblock the signal before doing anything
which can do FILE* operations.  And set the handler again?  Or just
leave the next signal to abort the process?  I dunno...

Anyway, if you don't do that, just apply the save/restore of errno.
Drop the 'if (errno != save_errno)' before restoring, that bit of
paranoia was turned down in Issue10311.
msg221668 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-06-27 00:05
intrcheck.c no longer exists in cpython so can this be closed "out of date"?
msg221677 - (view) Author: PCManticore (Claudiu.Popa) * (Python triager) Date: 2014-06-27 06:16
It's still in Python 2, though.
msg382080 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-11-29 17:21
This is a python 2-only issue.
History
Date User Action Args
2022-04-11 14:57:08adminsetgithub: 54521
2020-11-29 17:21:26iritkatrielsetstatus: open -> closed

nosy: + iritkatriel
messages: + msg382080

resolution: out of date
stage: resolved
2019-04-26 20:33:32BreamoreBoysetnosy: - BreamoreBoy
2014-09-02 13:00:41Claudiu.Popasetnosy: - Claudiu.Popa
2014-06-27 06:16:36Claudiu.Popasetstatus: closed -> open

versions: - Python 3.1, Python 3.2
nosy: + Claudiu.Popa

messages: + msg221677
resolution: out of date -> (no value)
stage: resolved -> (no value)
2014-06-27 06:13:12Claudiu.Popasetstatus: open -> closed
resolution: out of date
stage: resolved
2014-06-27 00:05:06BreamoreBoysetnosy: + BreamoreBoy
messages: + msg221668
2011-01-03 23:48:54pitrousetnosy: + vstinner
2010-11-09 08:42:22hfurusetmessages: + msg120845
2010-11-04 13:19:21hfurusetversions: + Python 3.1, Python 2.7
2010-11-04 12:50:10pitrousetnosy: + benjamin.peterson
2010-11-04 12:49:00hfurucreate