[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2021-05-05 Thread Irit Katriel


Irit Katriel  added the comment:

This was fixed in 3.9+ and 3.8 is in security fix now, so closing.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2021-01-13 Thread Mark Shannon


Change by Mark Shannon :


--
nosy: +lukasz.langa

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2021-01-13 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:

> Pablo, are you OK closing this without a 3.8 backport?

I would be supportive, but we should check with Ɓukasz as he is the release 
manager of 3.8

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2021-01-13 Thread Mark Shannon


Mark Shannon  added the comment:

Pablo, are you OK closing this without a 3.8 backport?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2021-01-13 Thread Irit Katriel


Irit Katriel  added the comment:

There were additional merge conflicts when I tried to create a manual 3.8 
backport, more significant than the 3.9 ones IIRC.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2021-01-13 Thread Mark Shannon


Mark Shannon  added the comment:

Does this need backporting to 3.8, or is 3.9 sufficient?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2020-11-17 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 48a9c0eb2a3304ea64d1b32fdf9db853d5d8c429 by Irit Katriel in 
branch '3.9':
[3.9] bpo-39934: Account for control blocks in 'except' in compiler. (GH-22395) 
(GH-23303)
https://github.com/python/cpython/commit/48a9c0eb2a3304ea64d1b32fdf9db853d5d8c429


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2020-11-15 Thread Irit Katriel


Change by Irit Katriel :


--
pull_requests: +22194
pull_request: https://github.com/python/cpython/pull/23303

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2020-10-07 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

PR 22395 should be backported to 3.8 and 3.9

--
nosy: +pablogsal

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2020-10-07 Thread Irit Katriel


Irit Katriel  added the comment:

After studying Mark's patch and the rest of the code, I understand the for loop 
oddity.

The else block of the for loop comes after the 
compiler_pop_fblock(c, FOR_LOOP, start);

So you can do this all day and it won't complain:

for x in '1': pass
else:
 for x in '2': pass
 else:
  for x in '3': pass
  else:
   for x in '4': pass
   else:
for x in '5': pass
else:
 for x in '6': pass
 else:
  for x in '7': pass
  else:
   for x in '8': pass
   else:
for x in '9': pass
else:
 for x in '10': pass
 else:
  for x in '11': pass
  else:
   for x in '12': pass
   else:
for x in '13': pass
else:
 for x in '14': pass
 else:
  for x in '15': pass
  else:
   for x in '16': pass
   else:
for x in '17': pass
else:
 for x in '18': pass
 else:
  for x in '19': pass
  else:
   for x in '20': pass
   else:
for x in '21': pass
else:
 for x in '22': pass
 else:
  for x in '23': pass
  else:
   for x in '24': pass
   else:
for x in '25': pass
else:
 for x in '26': pass
 else:
  for x in '27': pass
  else:
   for x in '28': pass
   else:
for x in '29': pass



I guess the same goes for while loops, and the else of a try-except.


Since If blocks were deliberately left out of this game, I'm assuming that this 
"static nesting" is actually number of frames, rather than true static nesting. 
If that is the case then there is no issue here and we can close this ticket.

But if this is something to be fixed, then I am happy to make a patch along the 
lines of Mark's (which I partially already have).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2020-09-25 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 02d126aa09d96d03dcf9c5b51c858ce5ef386601 by Mark Shannon in 
branch 'master':
bpo-39934: Account for control blocks in 'except' in compiler. (GH-22395)
https://github.com/python/cpython/commit/02d126aa09d96d03dcf9c5b51c858ce5ef386601


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2020-09-24 Thread Mark Shannon


Change by Mark Shannon :


--
keywords: +patch
pull_requests: +21435
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22395

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2020-09-24 Thread Irit Katriel


Irit Katriel  added the comment:

On windows 10, master:

> python.bat --version
Running Release|Win32 interpreter...
Python 3.10.0a0

>python.bat x.py
Running Release|Win32 interpreter...
SyntaxError: too many statically nested blocks

That's when x.py has the nested for loops without else. The error goes away if 
I add the else.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2020-09-24 Thread Mark Shannon


Mark Shannon  added the comment:

iritkatriel

What error do you see and on what version?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2020-09-24 Thread Irit Katriel


Irit Katriel  added the comment:

Another oddity:

This gives the error:
for x in '1':
 for x in '2':
  for x in '3':
   for x in '4':
for x in '5':
 for x in '6':
  for x in '8':
   for x in '9':
for x in '10':
 for x in '11':
  for x in '12':
   for x in '13':
for x in '14':
 for x in '15':
  for x in '16':
   for x in '17':
for x in '18':
 for x in '19':
  for x in '20':
   for x in '21':
for x in '22':
 pass

but this doesn't:

for x in '1':
 for x in '2':
  for x in '3':
   for x in '4':
for x in '5':
 for x in '6':
  for x in '8':
   for x in '9':
for x in '10':
 for x in '11':
  for x in '12':
   for x in '13':
for x in '14':
 for x in '15':
  for x in '16':
   for x in '17':
for x in '18':
 for x in '19':
  for x in '20':
   for x in '21':
pass
   else:
for x in '22':
 pass

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2020-09-24 Thread Irit Katriel


Irit Katriel  added the comment:

Unlike the 22 nested while,

if 1:
  if 2:
...
if 22:
pass

doesn't error. Is that correct?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2020-09-24 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Humm, my supposition was not absolutely correct. The cause is that the compiler 
and the interpreter use the stack of size CO_MAXBLOCKS for different things. 
The interpreter pushes a thing for the "except" clause, while the compiler does 
not do it.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2020-09-24 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is a bug. Compiler explicitly checks if the number of nested "try" blocks 
does not exceed the limit of CO_MAXBLOCKS, but it does not count implicit "try" 
blocks inserted when your assign an exception in the "except" clause.

try:
...
except Exception as e:
...

is actually translated to

try:
...
except Exception:
try:
e = ...
...
finally:
e = None
del e

So we have double number of nested "try" blocks.

--
nosy: +Mark.Shannon, serhiy.storchaka
type: behavior -> crash
versions: +Python 3.10, Python 3.8, Python 3.9 -Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2020-09-23 Thread Irit Katriel


Irit Katriel  added the comment:

The error is coming from here: 
https://github.com/python/cpython/blob/cb9879b948a19c9434316f8ab6aba9c4601a8173/Objects/frameobject.c#L958

and CO_MAXBLOCKS is defined in Include/cpython/code.h
#define CO_MAXBLOCKS 20 /* Max static block nesting within a function */

This is not about recursion or about exception, it's about static nesting 
level. 

There is an example here showing an input that gives the same error with >20 
nested while blocks: 
https://github.com/python/cpython/blob/c8f29ad986f8274fc5fbf889bdd2a211878856b9/Lib/test/test_syntax.py#L545

--
nosy: +iritkatriel

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2020-09-23 Thread Irit Katriel


Irit Katriel  added the comment:

In summary, I think this is not-a-bug.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39934] Fatal Python error "XXX block stack overflow" when exception stacks >10

2020-03-11 Thread myzhang1029


New submission from myzhang1029 :

I apologize for describing this issue badly, but I'll try anyway.
The code to demonstrate the issue is attached, so it might be better to read 
that instead.
I noticed that when more than 10 exceptions are raised sequentially (i.e. one 
from another or one during the handling of another), the interpreter crashes 
saying "Fatal Python error: XXX block stack overflow".
This happens in python 3.7, 3.8 and development(git 39c3493) versions, but not 
in python2.7. Using ipython also fixes this issue.
I know this case is rare, but the maximum number of recursions is more than 
2000, and the maximum number of statically nested blocks sepcified in 
frameobject.c is 20, so I'm pretty sure this isn't intended behavior.

--
components: Interpreter Core
files: exception_nest.py
messages: 363914
nosy: myzhang1029
priority: normal
severity: normal
status: open
title: Fatal Python error "XXX block stack overflow" when exception stacks >10
type: behavior
versions: Python 3.7
Added file: https://bugs.python.org/file48969/exception_nest.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com