[issue37830] continue in finally with return in try results with segfault
Serhiy Storchaka
report at bugs.python.org
Mon Aug 12 07:32:42 EDT 2019
Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:
Thank you for your report Batuhan.
But PR 15221 is not proper way to fix it. It will not work when return an iterable. This issue should be fixed at compiler level. The generated code is:
Disassembly of <code object simple at 0x7f2195c7d450, file "<stdin>", line 1>:
2 0 LOAD_GLOBAL 0 (range)
2 LOAD_CONST 1 (2)
4 CALL_FUNCTION 1
6 GET_ITER
>> 8 FOR_ITER 24 (to 34)
10 STORE_FAST 0 (number)
3 12 SETUP_FINALLY 12 (to 26)
4 14 LOAD_FAST 0 (number)
16 POP_BLOCK
18 CALL_FINALLY 6 (to 26)
20 ROT_TWO
22 POP_TOP
24 RETURN_VALUE
6 >> 26 POP_FINALLY 0
28 JUMP_ABSOLUTE 8
30 END_FINALLY
32 JUMP_ABSOLUTE 8
>> 34 LOAD_CONST 0 (None)
36 RETURN_VALUE
The return statement pushes a value at the stack (offset 14) and the continue statement jumps to the beginning of the loop (offset 28). The stack is not balanced here.
----------
assignee: -> serhiy.storchaka
nosy: +Mark.Shannon
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37830>
_______________________________________
More information about the Python-bugs-list
mailing list