Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s_push: parser stack overflow MemoryError #48221

Closed
netcaf mannequin opened this issue Sep 26, 2008 · 3 comments
Closed

s_push: parser stack overflow MemoryError #48221

netcaf mannequin opened this issue Sep 26, 2008 · 3 comments
Labels
performance Performance or resource usage

Comments

@netcaf
Copy link
Mannequin

netcaf mannequin commented Sep 26, 2008

BPO 3971
Nosy @benjaminp

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2008-09-26.21:54:46.851>
created_at = <Date 2008-09-26.09:23:32.155>
labels = ['performance']
title = 's_push: parser stack overflow MemoryError'
updated_at = <Date 2018-06-25.09:12:45.897>
user = 'https://bugs.python.org/netcaf'

bugs.python.org fields:

activity = <Date 2018-06-25.09:12:45.897>
actor = 'ait'
assignee = 'none'
closed = True
closed_date = <Date 2008-09-26.21:54:46.851>
closer = 'benjamin.peterson'
components = []
creation = <Date 2008-09-26.09:23:32.155>
creator = 'netcaf'
dependencies = []
files = []
hgrepos = []
issue_num = 3971
keywords = []
message_count = 3.0
messages = ['73839', '73897', '320405']
nosy_count = 3.0
nosy_names = ['benjamin.peterson', 'netcaf', 'ait']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = 'resource usage'
url = 'https://bugs.python.org/issue3971'
versions = ['Python 3.0']

@netcaf
Copy link
Mannequin Author

netcaf mannequin commented Sep 26, 2008

t =
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((0x280000))+(0x80000)-1)/(0x80000))*(0x80000))
+ 0x280000))+(0x10000)-1)/(0x10000))*(0x10000))+((0x10000*31
))))+(0x1000)-1)/(0x1000))*(0x1000)))+(16)-1)/(16))*(16)) +
0x100000))+(512)-1)/(512))*(512)) + 0xBF4000))+(8)-1)/(8))*(8)) +
0x200000) + 0x524000L)+(0x1000)-1)/(0x1000))*(0x1000)))+(3*253)) +
0))+(0x1000)-1)/(0x1000))*(0x1000)) +
0))+(0x1000)-1)/(0x1000))*(0x1000))+0x2B0000L))+(0x1000)-1)/(0x1000))*(0x1000))+0x4000)
+ 0))+(0x1000)-1)/(0x1000))*(0x1000))+0x600000L) +
0))+(0x1000)-1)/(0x1000))*(0x1000))+0x4000) +
0))+(0x1000)-1)/(0x1000))*(0x1000))+0x900000U) +
0))+(0x1000)-1)/(0x1000))*(0x1000)))+(0x2000)) +
0)+(0x1000)-1)/(0x1000))*(0x1000)) +
0x800L)+(0x1000)-1)/(0x1000))*(0x1000))+0x600000L)+0))+(0x1000)-1)/(0x1000))*(0x1000))+(((((((((((((
( (((((1920L) <= (1920L)) * (1920L) + ((1920L) < (1920L)) * (1920L))
))&0xFFF0)+16) + (0) )* (1088L + (0)) * 2)+(64L)-1)/(64L))*(64L))) >=
((((((( ( ((((1680L) <= (1920L)) * (1680L) + ((1920L) < (1680L)) *
(1920L)))&0xFFF0)+16) + (0))* (((1050L) <= (1080)) * (1050L) + ((1080) <
(1050L)) * (1080)) * 3)+(64L)-1)/(64L))*(64L)))) * ((((((( ( (((((1920L)
<= (1920L)) * (1920L) + ((1920L) < (1920L)) * (1920L)) ))&0xFFF0)+16) +
(0) )* (1088L + (0)) * 2)+(64L)-1)/(64L))*(64L))) + (((((((( (
((((1680L) <= (1920L)) * (1680L) + ((1920L) < (1680L)) *
(1920L)))&0xFFF0)+16) + (0))* (((1050L) <= (1080)) * (1050L) + ((1080) <
(1050L)) * (1080)) * 3)+(64L)-1)/(64L))*(64L))) > ((((((( ( (((((1920L)
<= (1920L)) * (1920L) + ((1920L) < (1920L)) * (1920L)) ))&0xFFF0)+16) +
(0) )* (1088L + (0)) * 2)+(64L)-1)/(64L))*(64L)))) * ((((((( (
((((1680L) <= (1920L)) * (1680L) + ((1920L) < (1680L)) *
(1920L)))&0xFFF0)+16) + (0))* (((1050L) <= (1080)) * (1050L) + ((1080) <
(1050L)) * (1080)) * 3)+(64L)-1)/(64L))*(64L))))) >= (((((((((( (
((((1920L) <= (1920L)) * (1920L) + ((1920L) < (1920L)) *
(1920L)))&0xFFF0)+16) + (0) )* (1088L + (0)) *
3)+(64L)-1)/(64L))*(64L))) >= ((((((( ( ((((720L) <= (1920L)) * (720L) +
((1920L) < (720L)) * (1920L)))&0xFFF0)+16) + (0)) * (576L + (0)) *
3)+(64L)-1)/(64L))*(64L)))) * ((((((( ( ((((1920L) <= (1920L)) * (1920L)
+ ((1920L) < (1920L)) * (1920L)))&0xFFF0)+16) + (0) )* (1088L + (0)) *
3)+(64L)-1)/(64L))*(64L))) + (((((((( ( ((((720L) <= (1920L)) * (720L) +
((1920L) < (720L)) * (1920L)))&0xFFF0)+16) + (0)) * (576L + (0)) *
3)+(64L)-1)/(64L))*(64L))) > ((((((( ( ((((1920L) <= (1920L)) * (1920L)
+ ((1920L) < (1920L)) * (1920L)))&0xFFF0)+16) + (0) )* (1088L + (0)) *
3)+(64L)-1)/(64L))*(64L)))) * ((((((( ( ((((720L) <= (1920L)) * (720L) +
((1920L) < (720L)) * (1920L)))&0xFFF0)+16) + (0)) * (576L + (0)) *
3)+(64L)-1)/(64L))*(64L)))))) * (((((((((( ( (((((1920L) <= (1920L)) *
(1920L) + ((1920L) < (1920L)) * (1920L)) ))&0xFFF0)+16) + (0) )* (1088L
+ (0)) * 2)+(64L)-1)/(64L))*(64L))) >= ((((((( ( ((((1680L) <= (1920L))
* (1680L) + ((1920L) < (1680L)) * (1920L)))&0xFFF0)+16) + (0))*
(((1050L) <= (1080)) * (1050L) + ((1080) < (1050L)) * (1080)) *
3)+(64L)-1)/(64L))*(64L)))) * ((((((( ( (((((1920L) <= (1920L)) *
(1920L) + ((1920L) < (1920L)) * (1920L)) ))&0xFFF0)+16) + (0) )* (1088L
+ (0)) * 2)+(64L)-1)/(64L))*(64L))) + (((((((( ( ((((1680L) <= (1920L))
* (1680L) + ((1920L) < (1680L)) * (1920L)))&0xFFF0)+16) + (0))*
(((1050L) <= (1080)) * (1050L) + ((1080) < (1050L)) * (1080)) *
3)+(64L)-1)/(64L))*(64L))) > ((((((( ( (((((1920L) <= (1920L)) * (1920L)
+ ((1920L) < (1920L)) * (1920L)) ))&0xFFF0)+16) + (0) )* (1088L + (0)) *
2)+(64L)-1)/(64L))*(64L)))) * ((((((( ( ((((1680L) <= (1920L)) * (1680L)
+ ((1920L) < (1680L)) * (1920L)))&0xFFF0)+16) + (0))* (((1050L) <=
(1080)) * (1050L) + ((1080) < (1050L)) * (1080)) *
3)+(64L)-1)/(64L))*(64L))))) + ((((((((((( ( ((((1920L) <= (1920L)) *
(1920L) + ((1920L) < (1920L)) * (1920L)))&0xFFF0)+16) + (0) )* (1088L +
(0)) * 3)+(64L)-1)/(64L))*(64L))) >= ((((((( ( ((((720L) <= (1920L)) *
(720L) + ((1920L) < (720L)) * (1920L)))&0xFFF0)+16) + (0)) * (576L +
(0)) * 3)+(64L)-1)/(64L))*(64L)))) * ((((((( ( ((((1920L) <= (1920L)) *
(1920L) + ((1920L) < (1920L)) * (1920L)))&0xFFF0)+16) + (0) )* (1088L +
(0)) * 3)+(64L)-1)/(64L))*(64L))) + (((((((( ( ((((720L) <= (1920L)) *
(720L) + ((1920L) < (720L)) * (1920L)))&0xFFF0)+16) + (0)) * (576L +
(0)) * 3)+(64L)-1)/(64L))*(64L))) > ((((((( ( ((((1920L) <= (1920L)) *
(1920L) + ((1920L) < (1920L)) * (1920L)))&0xFFF0)+16) + (0) )* (1088L +
(0)) * 3)+(64L)-1)/(64L))*(64L)))) * ((((((( ( ((((720L) <= (1920L)) *
(720L) + ((1920L) < (720L)) * (1920L)))&0xFFF0)+16) + (0)) * (576L +
(0)) * 3)+(64L)-1)/(64L))*(64L))))) > (((((((((( ( (((((1920L) <=
(1920L)) * (1920L) + ((1920L) < (1920L)) * (1920L)) ))&0xFFF0)+16) + (0)
)* (1088L + (0)) * 2)+(64L)-1)/(64L))*(64L))) >= ((((((( ( ((((1680L) <=
(1920L)) * (1680L) + ((1920L) < (1680L)) * (1920L)))&0xFFF0)+16) + (0))*
(((1050L) <= (1080)) * (1050L) + ((1080) < (1050L)) * (1080)) *
3)+(64L)-1)/(64L))*(64L)))) * ((((((( ( (((((1920L) <= (1920L)) *
(1920L) + ((1920L) < (1920L)) * (1920L)) ))&0xFFF0)+16) + (0) )* (1088L
+ (0)) * 2)+(64L)-1)/(64L))*(64L))) + (((((((( ( ((((1680L) <= (1920L))
* (1680L) + ((1920L) < (1680L)) * (1920L)))&0xFFF0)+16) + (0))*
(((1050L) <= (1080)) * (1050L) + ((1080) < (1050L)) * (1080)) *
3)+(64L)-1)/(64L))*(64L))) > ((((((( ( (((((1920L) <= (1920L)) * (1920L)
+ ((1920L) < (1920L)) * (1920L)) ))&0xFFF0)+16) + (0) )* (1088L + (0)) *
2)+(64L)-1)/(64L))*(64L)))) * ((((((( ( ((((1680L) <= (1920L)) * (1680L)
+ ((1920L) < (1680L)) * (1920L)))&0xFFF0)+16) + (0))* (((1050L) <=
(1080)) * (1050L) + ((1080) < (1050L)) * (1080)) *
3)+(64L)-1)/(64L))*(64L)))))) * (((((((((( ( ((((1920L) <= (1920L)) *
(1920L) + ((1920L) < (1920L)) * (1920L)))&0xFFF0)+16) + (0) )* (1088L +
(0)) * 3)+(64L)-1)/(64L))*(64L))) >= ((((((( ( ((((720L) <= (1920L)) *
(720L) + ((1920L) < (720L)) * (1920L)))&0xFFF0)+16) + (0)) * (576L +
(0)) * 3)+(64L)-1)/(64L))*(64L)))) * ((((((( ( ((((1920L) <= (1920L)) *
(1920L) + ((1920L) < (1920L)) * (1920L)))&0xFFF0)+16) + (0) )* (1088L +
(0)) * 3)+(64L)-1)/(64L))*(64L))) + (((((((( ( ((((720L) <= (1920L)) *
(720L) + ((1920L) < (720L)) * (1920L)))&0xFFF0)+16) + (0)) * (576L +
(0)) * 3)+(64L)-1)/(64L))*(64L))) > ((((((( ( ((((1920L) <= (1920L)) *
(1920L) + ((1920L) < (1920L)) * (1920L)))&0xFFF0)+16) + (0) )* (1088L +
(0)) * 3)+(64L)-1)/(64L))*(64L)))) * ((((((( ( ((((720L) <= (1920L)) *
(720L) + ((1920L) < (720L)) * (1920L)))&0xFFF0)+16) + (0)) * (576L +
(0)) * 3)+(64L)-1)/(64L))*(64L)))))) * 2)) +
0)+0x80)+0))+(8)-1)/(8))*(8)))+0x3600)+0))+(8)-1)/(8))*(8)))+0x400))+(8)-1)/(8))*(8))
+ 0)+(0x0))+(0x0))+(4096)-1)/(4096))*(4096)) +
0x1000)+(0x1000)-1)/(0x1000))*(0x1000)) +
0x1000)+(0x1000)-1)/(0x1000))*(0x1000))

@netcaf netcaf mannequin added the performance Performance or resource usage label Sep 26, 2008
@benjaminp
Copy link
Contributor

This really abuse of the parser. If you really need this, you can bump
MAXSTACK in Parser/parser.h to a higher number.

@ait
Copy link
Mannequin

ait mannequin commented Jun 25, 2018

Also affected, a code generator produced deeply nested code with the structure depicted below and then crashed:

#!/usr/bin/python2 -BEsStt
A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A([A(None)])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])])

What would be the maximal nesting depth a generator can always expect to be compiled successfully on Python 2.7 and 3.5 on? Are there any other similar restrictions that need to be considered when writing a code generator? Or is generating code that way not the preferred solution anyway - the code generator should generate e.g. compiled binary Python code immediately?

Note: in the end the exact same logic code will run as Python process, it is only about how it is loaded into the Python interpreter. Different from the code example in the bug create message, code with similar properties to the one from this example is generated to evaluate a mathematical model, thus not that random and meaningless compared to the putative fuzzer output from the first note.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance or resource usage
Projects
None yet
Development

No branches or pull requests

1 participant