cpython/Modules
Nathaniel J. Smith ab4413a7e9 bpo-30039: Don't run signal handlers while resuming a yield from stack (#1081)
If we have a chain of generators/coroutines that are 'yield from'ing
each other, then resuming the stack works like:

- call send() on the outermost generator
- this enters _PyEval_EvalFrameDefault, which re-executes the
  YIELD_FROM opcode
- which calls send() on the next generator
- which enters _PyEval_EvalFrameDefault, which re-executes the
  YIELD_FROM opcode
- ...etc.

However, every time we enter _PyEval_EvalFrameDefault, the first thing
we do is to check for pending signals, and if there are any then we
run the signal handler. And if it raises an exception, then we
immediately propagate that exception *instead* of starting to execute
bytecode. This means that e.g. a SIGINT at the wrong moment can "break
the chain" – it can be raised in the middle of our yield from chain,
with the bottom part of the stack abandoned for the garbage collector.

The fix is pretty simple: there's already a special case in
_PyEval_EvalFrameEx where it skips running signal handlers if the next
opcode is SETUP_FINALLY. (I don't see how this accomplishes anything
useful, but that's another story.) If we extend this check to also
skip running signal handlers when the next opcode is YIELD_FROM, then
that closes the hole – now the exception can only be raised at the
innermost stack frame.

This shouldn't have any performance implications, because the opcode
check happens inside the "slow path" after we've already determined
that there's a pending signal or something similar for us to process;
the vast majority of the time this isn't true and the new check
doesn't run at all.
2017-05-17 13:33:23 -07:00
..
_blake2 Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
_ctypes bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() (#1096) 2017-04-19 20:03:52 +03:00
_decimal Correct typo (#976) 2017-04-03 18:16:14 +02:00
_io bpo-30228: FileIO seek() and tell() set seekable (#1384) 2017-05-02 15:10:39 +02:00
_multiprocessing bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
_sha3 Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
_sqlite Use NULL rather than 0. (#778) 2017-03-23 17:53:47 +02:00
cjkcodecs bpo-29990: Fix range checking in GB18030 decoder (#1495) 2017-05-09 11:38:32 +08:00
clinic bpo-30285: Optimize case-insensitive matching and searching (#1482) 2017-05-09 23:37:14 +03:00
expat
zlib - Issue #29169: Update zlib to 1.2.10. 2017-01-31 13:49:48 +01:00
README
Setup.config.in
Setup.dist
_asynciomodule.c bpo-30048: asyncio: fix Task.cancel() was ignored. (GH-1097) 2017-05-11 21:18:38 +09:00
_bisectmodule.c
_bz2module.c bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
_codecsmodule.c bpo-24037: Add Argument Clinic converter `bool(accept={int})`. (#485) 2017-03-12 10:10:47 +02:00
_collectionsmodule.c bpo-29935: Fixed error messages in the index() method of tuple, list and deque (#887) 2017-03-30 18:29:23 +03:00
_cryptmodule.c
_csv.c Use NULL rather than 0. (#778) 2017-03-23 17:53:47 +02:00
_curses_panel.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
_cursesmodule.c bpo-30101: Add support for curses.A_ITALIC. (#1015) 2017-04-26 23:17:12 +08:00
_datetimemodule.c bpo-29953: Fix memory leaks in the replace() method of datetime and time (#927) 2017-03-31 22:48:16 +03:00
_dbmmodule.c bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
_elementtree.c bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() (#1096) 2017-04-19 20:03:52 +03:00
_functoolsmodule.c bpo-29878: Add global instances of int for 0 and 1. (#852) 2017-03-30 09:09:41 +03:00
_gdbmmodule.c bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
_hashopenssl.c _hashopenssl uses METH_FASTCALL 2017-01-17 04:20:26 +01:00
_heapqmodule.c
_json.c bpo-30243: Fixed the possibility of a crash in _json. (#1420) 2017-05-05 10:08:49 +03:00
_localemodule.c allow the first call to wcsxfrm to return ERANGE (#536) 2017-03-07 22:24:44 -08:00
_lsprof.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
_lzmamodule.c
_math.c
_math.h
_opcode.c
_operator.c Issue #29460: _PyArg_NoKeywords(), _PyArg_NoStackKeywords() and 2017-02-06 10:41:46 +02:00
_pickle.c bpo-29865: Use PyXXX_GET_SIZE macros rather than Py_SIZE for concrete types. (#748) 2017-03-21 08:53:25 +02:00
_posixsubprocess.c bpo-30065: Fixed arguments validation in _posixsubprocess.fork_exec(). (#1110) 2017-04-19 21:12:46 +03:00
_randommodule.c bpo-29960 _random.Random corrupted on exception in setstate(). (#1019) 2017-04-22 09:10:46 +03:00
_scproxy.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
_sre.c bpo-30285: Optimize case-insensitive matching and searching (#1482) 2017-05-09 23:37:14 +03:00
_ssl.c bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
_ssl_data.h
_stat.c
_struct.c bpo-30242: resolve some undefined behaviours in struct (#1418) 2017-05-15 12:04:26 +08:00
_testbuffer.c Expand the PySlice_GetIndicesEx macro. (#1023) 2017-04-08 09:53:51 +03:00
_testcapimodule.c bpo-30039: Don't run signal handlers while resuming a yield from stack (#1081) 2017-05-17 13:33:23 -07:00
_testimportmultiple.c
_testmultiphase.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
_threadmodule.c bpo-6532: Make the thread id an unsigned integer. (#781) 2017-03-23 14:48:39 +01:00
_tkinter.c Use NULL rather than 0. (#778) 2017-03-23 17:53:47 +02:00
_tracemalloc.c Issue #20186: Regenerated Argument Clinic. 2017-02-05 22:58:46 +02:00
_weakref.c
_winapi.c bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() (#1096) 2017-04-19 20:03:52 +03:00
addrinfo.h
arraymodule.c Expand the PySlice_GetIndicesEx macro. (#1023) 2017-04-08 09:53:51 +03:00
atexitmodule.c
audioop.c
binascii.c bpo-30103: Allow Uuencode in Python using backtick as zero instead of space (#1326) 2017-05-03 11:16:21 +08:00
cmathmodule.c
config.c.in
errnomodule.c
faulthandler.c bpo-30125: Fix faulthandler.disable() on Windows (#1240) 2017-04-21 18:06:13 +02:00
fcntlmodule.c bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
fpectlmodule.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
fpetestmodule.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
gc_weakref.txt
gcmodule.c Issue #20185: Converted the gc module to Argument Clinic. 2017-02-04 11:19:59 +02:00
getaddrinfo.c
getbuildinfo.c bpo-27593: Get SCM build info from git instead of hg. (#446) 2017-03-04 00:19:55 -05:00
getnameinfo.c
getpath.c
grpmodule.c
hashlib.h
hashtable.c
hashtable.h
itertoolsmodule.c bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() (#1096) 2017-04-19 20:03:52 +03:00
ld_so_aix.in
main.c bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
makesetup merge 3.6 2017-01-16 00:05:54 -08:00
makexp_aix
mathmodule.c bpo-29962: add math.remainder (#950) 2017-04-05 18:34:27 +01:00
md5module.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
mmapmodule.c Expand the PySlice_GetIndicesEx macro. (#1023) 2017-04-08 09:53:51 +03:00
nismodule.c
ossaudiodev.c bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
overlapped.c
parsermodule.c bpo-30070: Fixed leaks and crashes in errors handling in the parser module. (#1131) 2017-04-19 21:09:21 +03:00
posixmodule.c bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() (#1096) 2017-04-19 20:03:52 +03:00
posixmodule.h
pwdmodule.c
pyexpat.c bpo-24037: Add Argument Clinic converter `bool(accept={int})`. (#485) 2017-03-12 10:10:47 +02:00
readline.c bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
resource.c bpo-20185: Convert the resource moduel to Argument Clinic. (#545) 2017-03-12 13:08:30 +02:00
rotatingtree.c
rotatingtree.h
selectmodule.c bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() (#1096) 2017-04-19 20:03:52 +03:00
sha1module.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
sha256module.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
sha512module.c Removed redundant Argument Clinic directives. 2017-02-04 11:53:22 +02:00
signalmodule.c bpo-30038: fix race condition in signal delivery + wakeup fd (#1082) 2017-05-16 23:12:11 +02:00
socketmodule.c bpo-30205: Fix getsockname() for unbound AF_UNIX sockets on Linux (#1370) 2017-05-02 17:20:00 +02:00
socketmodule.h Add sockaddr_alg to sock_addr_t (#234) 2017-02-22 12:12:00 +01:00
spwdmodule.c
sre.h
sre_constants.h bpo-30215: Make re.compile() locale agnostic. (#1361) 2017-05-05 08:53:40 +03:00
sre_lib.h bpo-30215: Make re.compile() locale agnostic. (#1361) 2017-05-05 08:53:40 +03:00
symtablemodule.c Issue #20186: Converted the symtable module to Argument Clinic. 2017-02-04 12:13:20 +02:00
syslogmodule.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
termios.c Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever 2017-01-23 09:47:21 +02:00
testcapi_long.h
timemodule.c timemodule.c: Cast PyUnicode_AsUTF8() to char* (#1294) 2017-04-26 13:51:48 +02:00
tkappinit.c
tkinter.h
unicodedata.c
unicodedata_db.h
unicodename_db.h
winreparse.h
xxlimited.c merge 3.5 (#29398) 2017-01-31 23:31:10 -08:00
xxmodule.c
xxsubtype.c
zipimport.c bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
zlibmodule.c

README

Source files for standard library extension modules,
and former extension modules that are now builtin modules.