classification
Title: Parser stack overflows
Type: Stage: resolved
Components: Versions: Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: s_push: parser stack overflow MemoryError
View: 3971
Assigned To: Nosy List: Isaac Elliott, pablogsal
Priority: normal Keywords:

Created on 2018-03-26 23:57 by Isaac Elliott, last changed 2018-03-27 14:41 by ned.deily. This issue is now closed.

Messages (3)
msg314485 - (view) Author: Isaac Elliott (Isaac Elliott) Date: 2018-03-26 23:57
python3's parser stack overflows on deeply-nested expressions, for example:

[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

or

aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

These are both minimal examples, so if you remove one level of nesting from either then python3 will behave normally.
msg314486 - (view) Author: Isaac Elliott (Isaac Elliott) Date: 2018-03-27 00:20
Because of the way recursive descent parsing works,

[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[

is actually the minimal input required to reproduce this in python3.

In python2, the bug is still present, but requires a slightly deeper nesting:

[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
msg314497 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2018-03-27 03:31
Duplicate of issue3971
History
Date User Action Args
2018-03-27 14:41:15ned.deilysetstatus: open -> closed
stage: resolved
2018-03-27 03:31:35pablogsalsetresolution: duplicate
2018-03-27 03:31:28pablogsalsetnosy: + pablogsal
messages: + msg314497
2018-03-27 03:30:58pablogsalsetsuperseder: s_push: parser stack overflow MemoryError
2018-03-27 00:20:40Isaac Elliottsetmessages: + msg314486
2018-03-26 23:57:23Isaac Elliottcreate