Issue 10312: intcatcher() can deadlock (original) (raw)

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:08 admin set github: 54521
2020-11-29 17:21:26 iritkatriel set status: open -> closednosy: + iritkatrielmessages: + resolution: out of datestage: resolved
2019-04-26 20:33:32 BreamoreBoy set nosy: - BreamoreBoy
2014-09-02 13:00:41 Claudiu.Popa set nosy: - Claudiu.Popa
2014-06-27 06:16:36 Claudiu.Popa set status: closed -> openversions: - Python 3.1, Python 3.2nosy: + Claudiu.Popamessages: + resolution: out of date -> (no value)stage: resolved -> (no value)
2014-06-27 06:13:12 Claudiu.Popa set status: open -> closedresolution: out of datestage: resolved
2014-06-27 00:05:06 BreamoreBoy set nosy: + BreamoreBoymessages: +
2011-01-03 23:48:54 pitrou set nosy: + vstinner
2010-11-09 08:42:22 hfuru set messages: +
2010-11-04 13:19:21 hfuru set versions: + Python 3.1, Python 2.7
2010-11-04 12:50:10 pitrou set nosy: + benjamin.peterson
2010-11-04 12:49:00 hfuru create