cpython/Modules
Yury Selivanov e89f95bfd0 [3.6] bpo-30039: Don't run signal handlers while resuming a yield from stack (GH-1081) (#1640)
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..
(cherry picked from commit ab4413a7e9)
2017-06-09 17:06:39 -04:00
..
_blake2 more PY_LONG_LONG to long long 2016-09-08 09:15:54 -07:00
_ctypes Expand the PySlice_GetIndicesEx macro. (#1023) (#1044) 2017-04-08 11:18:14 +03:00
_decimal Merge 3.5. 2017-01-09 13:11:51 +01:00
_io bpo-30601: Fix a refleak in WindowsConsoleIO (#2003) (#2008) 2017-06-08 23:13:12 +02:00
_multiprocessing require a long long data type (closes #27961) 2016-09-05 17:44:18 -07:00
_sha3 Don't define PY_WITH_KECCAK 2016-09-21 14:36:44 +02:00
_sqlite bpo-28518: Start a transaction implicitly before a DML statement (#245) (#318) 2017-02-26 19:09:10 +03:00
cjkcodecs bpo-30003: Fix handling escape characters in HZ codec (#1556) (#1719) 2017-05-23 01:03:00 +08:00
clinic [3.6] bpo-19180: Updated references for RFC 1750, RFC 3280 & RFC 4366 2017-06-09 22:37:53 +10:00
expat revert expat changes 2016-09-19 22:20:13 -07:00
zlib - Issue #29169: Update zlib to 1.2.10. 2017-01-31 13:49:48 +01:00
_asynciomodule.c bpo-30048: asyncio: fix Task.cancel() was ignored. (GH-1546) 2017-05-11 21:56:42 +09:00
_bisectmodule.c The return type of a rich comparison is an int 2016-02-14 01:41:35 -08:00
_bz2module.c Issue #28275: Merge bz2 fix from 3.5 into 3.6 2016-10-01 03:11:04 +00:00
_codecsmodule.c Issue #27781: Change file system encoding on Windows to UTF-8 (PEP 529) 2016-09-08 10:35:16 -07:00
_collectionsmodule.c bpo-29935: Fixed error messages in the index() method of tuple, list and deque (#887) (#907) 2017-03-30 19:46:59 +03:00
_cryptmodule.c Issue #27332: Fixed the type of the first argument of module-level functions 2016-07-07 17:35:15 +03:00
_csv.c Issue #27809: _csv: _call_dialect() uses fast call 2016-08-23 00:21:34 +02:00
_curses_panel.c Issue #25745: Fixed leaking a userptr in curses panel destructor. 2016-05-09 00:14:22 +03:00
_cursesmodule.c bpo-29176: Fix name of the _curses.window class (#52) (#532) 2017-03-08 17:19:57 +01:00
_datetimemodule.c bpo-29953: Fix memory leaks in the replace() method of datetime and t… (#933) 2017-03-31 23:23:49 +03:00
_dbmmodule.c - Issue #27332: Fixed the type of the first argument of module-level functions 2016-07-07 18:20:03 +03:00
_elementtree.c Expand the PySlice_GetIndicesEx macro. (#1023) (#1044) 2017-04-08 11:18:14 +03:00
_functoolsmodule.c bpo-29800: Fix crashes in partial.__repr__ if the keys of partial.keywords are not strings (#649) (#671) 2017-03-15 09:42:02 +02:00
_gdbmmodule.c - Issue #27332: Fixed the type of the first argument of module-level functions 2016-07-07 18:20:03 +03:00
_hashopenssl.c Issue #27895: Spelling fixes (Contributed by Ville Skyttä). 2016-09-07 12:03:06 +00:00
_heapqmodule.c Issue #15984: Merge PyUnicode doc from 3.5 2016-04-15 02:27:11 +00:00
_json.c [3.6] bpo-30243: Fixed the possibility of a crash in _json. (GH-1420) (#1469) 2017-05-05 10:40:30 +03:00
_localemodule.c Issue #28139: Merge indentation fixes from 3.5 into 3.6 2016-09-17 07:59:14 +00:00
_lsprof.c Issue #28701: Replace PyUnicode_CompareWithASCIIString with _PyUnicode_EqualToASCIIString. 2016-11-16 10:19:20 +02:00
_lzmamodule.c Issue #27517: LZMA compressor and decompressor no longer raise exceptions if 2016-10-31 08:31:13 +02:00
_math.c
_math.h
_opcode.c Issue #27332: Fixed the type of the first argument of module-level functions 2016-07-07 17:35:15 +03:00
_operator.c Issue #27809: methodcaller_reduce() uses fast call 2016-08-23 00:23:23 +02:00
_pickle.c Issue #29190: Fixed possible errors in comparing strings in the pickle module. 2017-01-09 10:09:43 +02:00
_posixsubprocess.c [3.6] bpo-30065: Fixed arguments validation in _posixsubprocess.fork_exec(). (GH-1110) (#1186) 2017-04-19 23:59:02 +03:00
_randommodule.c [3.6] bpo-29960 _random.Random corrupted on exception in setstate(). … (#1287) 2017-05-27 07:20:24 -07:00
_scproxy.c Eliminate a tautological-pointer-compare warning found by Clang. 2016-09-07 14:07:16 -07:00
_sre.c Issue #29444: Fixed out-of-bounds buffer access in the group() method of 2017-02-04 22:55:40 +02:00
_ssl.c [3.6] bpo-19180: Updated references for RFC 1750, RFC 3280 & RFC 4366 2017-06-09 22:37:53 +10:00
_ssl_data.h
_stat.c
_struct.c bpo-30242: resolve some undefined behaviours in struct (#1418) (#1586) 2017-05-15 13:17:28 +08:00
_testbuffer.c Expand the PySlice_GetIndicesEx macro. (#1023) (#1044) 2017-04-08 11:18:14 +03:00
_testcapimodule.c [3.6] bpo-30039: Don't run signal handlers while resuming a yield from stack (GH-1081) (#1640) 2017-06-09 17:06:39 -04:00
_testimportmultiple.c
_testmultiphase.c Merge #27782 fix from 3.5 2016-08-21 17:43:58 +10:00
_threadmodule.c Issue #27895: Spelling fixes (Contributed by Ville Skyttä). 2016-09-07 12:03:06 +00:00
_tkinter.c Fixed possible NULL decrefing. 2016-10-28 12:16:21 +03:00
_tracemalloc.c replace PY_SIZE_MAX with SIZE_MAX 2016-09-07 09:26:18 -07:00
_weakref.c Issue #28427: old keys should not remove new values from 2016-12-27 14:19:20 +01:00
_winapi.c bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() (#1096) (#1180) 2017-04-19 21:22:49 +03:00
addrinfo.h replace PY_LONG_LONG with long long 2016-09-06 10:46:49 -07:00
ar_beos
arraymodule.c Expand the PySlice_GetIndicesEx macro. (#1023) (#1044) 2017-04-08 11:18:14 +03:00
atexitmodule.c Issue #25523: Merge "a" to "an" fixes from 3.4 into 3.5 2015-11-02 04:04:57 +00:00
audioop.c Use uint16_t instead of short in audioop. 2016-09-11 14:48:16 +03:00
binascii.c Issue #29004: Merge crc_hqx() doc from 3.5 2016-12-24 07:44:03 +00:00
cmathmodule.c Issue 23229: add cmath.inf, cmath.nan, cmath.infj and cmath.nanj. 2016-08-29 13:56:58 +01:00
config.c.in PEP 489: Multi-phase extension module initialization 2015-05-23 22:24:10 +10:00
errnomodule.c
faulthandler.c [3.6] bpo-30557: faulthandler now correctly filters and displays exception … (#1960) 2017-06-06 13:47:14 -07:00
fcntlmodule.c Issue #28139: Fix messed up indentation 2016-09-17 03:26:16 +00:00
fpectlmodule.c
fpetestmodule.c
gc_weakref.txt
gcmodule.c Don't run garbage collection on interpreter exit if it was explicitly disabled 2016-09-09 21:47:46 -07:00
getaddrinfo.c Issue #26505: merge from 3.5 2016-03-07 14:52:46 -05:00
getbuildinfo.c [3.6] bpo-27593: Get SCM build info from git instead of hg. (#446) (#454) 2017-03-04 01:05:06 -05:00
getnameinfo.c
getpath.c Issue #19398: Extra slash no longer added to sys.path components in case of 2016-11-11 12:06:38 +02:00
grpmodule.c - Issue #27332: Fixed the type of the first argument of module-level functions 2016-07-07 18:20:03 +03:00
hashlib.h Issue #26798: Add BLAKE2 (blake2b and blake2s) to hashlib. 2016-09-06 22:03:25 +02:00
hashtable.c Issue #28126: Replace Py_MEMCPY with memcpy(). Visual Studio can properly optimize memcpy(). 2016-09-13 20:22:02 +02:00
hashtable.h Issue #28126: Replace Py_MEMCPY with memcpy(). Visual Studio can properly optimize memcpy(). 2016-09-13 20:22:02 +02:00
itertoolsmodule.c bpo-29942: Fix the use of recursion in itertools.chain.from_iterable. (#911) 2017-03-30 12:48:23 -07:00
ld_so_aix.in Issue #10656: Fix out-of-tree building on AIX 2016-11-20 07:56:37 +00:00
ld_so_beos
main.c [3.6] bpo-29723: Consistently configure sys.path[0] (#636) 2017-03-12 21:34:22 +10:00
makesetup generate spaces instead of tabs into config.c 2017-01-16 00:05:12 -08:00
makexp_aix
mathmodule.c Issue #27895: Spelling fixes (Contributed by Ville Skyttä). 2016-09-07 12:03:06 +00:00
md5module.c replace PY_LONG_LONG with long long 2016-09-06 10:46:49 -07:00
mmapmodule.c Expand the PySlice_GetIndicesEx macro. (#1023) (#1044) 2017-04-08 11:18:14 +03:00
nismodule.c Issue #24300: Minor refactoring. 2015-07-24 00:43:44 -04:00
ossaudiodev.c Issue #28715: Added error checks for PyUnicode_AsUTF8(). 2016-11-20 08:48:07 +02:00
overlapped.c Issue #27781: Change file system encoding on Windows to UTF-8 (PEP 529) 2016-09-08 10:35:16 -07:00
parsermodule.c [3.6] bpo-30070: Fixed leaks and crashes in errors handling in the parser module. (GH-1131). (#1184) 2017-04-19 23:22:19 +03:00
posixmodule.c bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() (#1096) (#1180) 2017-04-19 21:22:49 +03:00
posixmodule.h
pwdmodule.c - Issue #27332: Fixed the type of the first argument of module-level functions 2016-07-07 18:20:03 +03:00
pyexpat.c [3.6] bpo-29768: Fixed compile-time check for expat version. (#576) 2017-03-09 10:51:44 +02:00
readline.c explicitly cast away constness to silence compiler warning 2016-09-05 18:26:19 -07:00
README
resource.c Issue #20191: Fixed a crash in resource.prlimit() when pass a sequence that 2016-12-19 08:05:39 +02:00
rotatingtree.c
rotatingtree.h
selectmodule.c Issue #28153: Make kqueue()'s event filters optional 2016-09-14 18:16:59 +03:00
Setup.config.in remove --with(out)-signal-module, since the signal module is non-optional 2016-09-09 12:01:10 -07:00
Setup.dist Issue #28428: Rename _futures module to _asyncio. 2016-10-15 15:39:19 +09:00
sha1module.c replace PY_LONG_LONG with long long 2016-09-06 10:46:49 -07:00
sha256module.c Issue #27332: Fixed the type of the first argument of module-level functions 2016-07-07 17:35:15 +03:00
sha512module.c stop using Py_LL and Py_ULL 2016-09-18 18:12:21 -07:00
signalmodule.c Issue #28139: Merge indentation fixes from 3.5 into 3.6 2016-09-17 07:59:14 +00:00
socketmodule.c Backport bpo-30205 to 3.6 (#1403) 2017-05-03 00:14:29 +02:00
socketmodule.h Add sockaddr_alg to sock_addr_t (GH-234) (GH-533) 2017-03-16 20:59:36 -07:00
spwdmodule.c - Issue #27332: Fixed the type of the first argument of module-level functions 2016-07-07 18:20:03 +03:00
sre.h
sre_constants.h
sre_lib.h replace Py_(u)intptr_t with the c99 standard types 2016-09-06 13:47:26 -07:00
symtablemodule.c Issue #27985: Implement PEP 526 -- Syntax for Variable Annotations. 2016-09-08 20:50:03 -07:00
syslogmodule.c Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSize 2016-11-20 09:13:07 +02:00
termios.c
testcapi_long.h
timemodule.c tmtotuple(): use time_t for gmtoff (#1276) (#1635) 2017-05-17 14:45:45 -07:00
tkappinit.c
tkinter.h
unicodedata.c Add an extra byte for null in case we ever get very long unicode names. 2016-09-23 20:21:20 +02:00
unicodedata_db.h Unicode 9.0.0 2016-09-14 23:53:47 -07:00
unicodename_db.h Unicode 9.0.0 2016-09-14 23:53:47 -07:00
winreparse.h Issue #17599: Use unique _Py_REPARSE_DATA_BUFFER etc names to avoid conflict 2016-08-04 02:38:59 +00:00
xxlimited.c merge 3.5 (#29398) 2017-01-31 23:31:10 -08:00
xxmodule.c Issue #25923: Added more const qualifiers to signatures of static and private functions. 2015-12-25 20:01:53 +02:00
xxsubtype.c PEP 489: Multi-phase extension module initialization 2015-05-23 22:24:10 +10:00
zipimport.c bpo-29770: remove outdated PYO related info (GH-590) (GH-612) 2017-03-11 14:07:30 +08:00
zlibmodule.c Issue #28126: Replace Py_MEMCPY with memcpy(). Visual Studio can properly optimize memcpy(). 2016-09-13 20:22:02 +02:00

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