cpython/Misc
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
..
ACKS bpo-30357: test_thread now uses threading_cleanup() (#1592) 2017-05-15 17:55:32 +02:00
HISTORY Update Misc/NEWS and Misc/HISTORY from current 3.5 and 3.4 branches. 2017-01-20 10:35:46 -05:00
NEWS bpo-30039: Don't run signal handlers while resuming a yield from stack (#1081) 2017-05-17 13:33:23 -07:00
Porting Issue #10708: Add a link to devguide in Misc/Porting. 2015-08-25 07:18:21 +03:00
README merge 3.3 2015-02-18 08:55:38 -05:00
README.AIX
README.coverity
README.valgrind Add PYTHONMALLOC env var 2016-03-14 12:04:26 +01:00
SpecialBuilds.txt Issue #28799: Update Misc/SpecialBuilds.txt 2016-11-28 12:06:13 +01:00
coverity_model.c merge 3.5 (#28184) 2016-09-19 22:17:16 -07:00
gdbinit Removed unintentional trailing spaces in text files. 2015-03-29 19:12:58 +03:00
indent.pro
python-config.in - Issue #18096: Fix library order returned by python-config. 2014-10-02 02:00:14 +02:00
python-config.sh.in - Issue #25440: Fix output of python-config --extension-suffix. 2015-10-19 14:07:57 +02:00
python-wing3.wpr
python-wing4.wpr
python-wing5.wpr Issue 17457: extend test discovery to support namespace packages 2013-11-23 13:29:23 +00:00
python.man Issue #28532: Show sys.version when -V option is supplied twice 2016-11-21 20:57:14 +09:00
python.pc.in
svnmap.txt
valgrind-python.supp Valgrind: suppress false positive in _PyOS_GetOpt (getopt.c:84) (Invalid read 2013-11-08 20:18:09 +01:00
vgrindefs

README

Python Misc subdirectory
========================

This directory contains files that wouldn't fit in elsewhere.  Some
documents are only of historic importance.

Files found here
----------------

ACKS                    Acknowledgements
gdbinit                 Handy stuff to put in your .gdbinit file, if you use gdb
HISTORY                 News from previous releases -- oldest last
indent.pro              GNU indent profile approximating my C style
NEWS                    News for this release (for some meaning of "this")
Porting                 Mini-FAQ on porting to new platforms
python-config.in        Python script template for python-config
python.man              UNIX man page for the python interpreter
python.pc.in            Package configuration info template for pkg-config
python-wing*.wpr        Wing IDE project file
README                  The file you're reading now
README.AIX              Information about using Python on AIX
README.coverity         Information about running Coverity's Prevent on Python
README.valgrind         Information for Valgrind users, see valgrind-python.supp
SpecialBuilds.txt       Describes extra symbols you can set for debug builds
svnmap.txt              Map of old SVN revs and branches to hg changeset ids
valgrind-python.supp    Valgrind suppression file, see README.valgrind
vgrindefs               Python configuration for vgrind (a generic pretty printer)