Issue 3971: s_push: parser stack overflow MemoryError (original) (raw)

Issue3971

Created on 2008-09-26 09:23 by netcaf, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg73839 - (view) Author: netcaf (netcaf) Date: 2008-09-26 09:23
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))
msg73897 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-09-26 21:54
This really abuse of the parser. If you really need this, you can bump MAXSTACK in Parser/parser.h to a higher number.
msg320405 - (view) Author: (ait) Date: 2018-06-25 09:12
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.
History
Date User Action Args
2022-04-11 14:56:39 admin set github: 48221
2018-06-25 09:12:45 ait set nosy: + aitmessages: +
2018-03-27 03:30:58 pablogsal link issue33149 superseder
2008-09-26 21:54:46 benjamin.peterson set status: open -> closedresolution: wont fixmessages: + nosy: + benjamin.peterson
2008-09-26 09:23:32 netcaf create