[issue17288] cannot jump from a return after setting f_lineno

Xavier de Gaye report at bugs.python.org
Tue Jul 8 12:58:00 CEST 2014


Xavier de Gaye added the comment:

Python 3.5 is still crashing with this test:

$ python jump.py
> jump.py(7)<module>()
-> for i in gen():
(Pdb) break 3
Breakpoint 1 at jump.py:3
(Pdb) continue
> jump.py(3)gen()
-> yield i
(Pdb) step
--Return--
> jump.py(3)gen()->0
-> yield i
(Pdb) jump 2
> jump.py(2)gen()->0
-> for i in range(1):
(Pdb) continue
Segmentation fault (core dumped)


It is true that frame_setlineno() assumes incorrectly that f->f_stacktop is not NULL, but the reason of the crash or of the "SystemError: unknown opcode" is that PyEval_EvalFrameEx() expects on its invocation f->f_lasti to refer to the index of the last instruction executed and sets (and assumes this instruction does not have argument) 'next_instr' accordingly to the next byte, while by jumping to line 2 we set f->f_lasti to zero and 'SETUP_LOOP', the opcode at this index, has an argument.

The attached patch is a slight improvement over the last one.

----------
type: behavior -> crash
versions: +Python 3.5 -Python 2.7, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file35898/default_2.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17288>
_______________________________________


More information about the Python-bugs-list mailing list