Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.093 X-Spam-Evidence: '*H*': 0.82; '*S*': 0.00; 'cpython': 0.05; 'pypy': 0.07; 'cc:addr:python-list': 0.09; 'attack.': 0.09; 'exceeds': 0.09; 'exception': 0.13; 'stack': 0.13; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'joonas': 0.16; 'liik': 0.16; 'somehow.': 0.16; 'try?': 0.16; 'wrote:': 0.16; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'parser': 0.22; 'am,': 0.23; 'bigger': 0.23; 'header:In-Reply-To:1': 0.24; 'example': 0.26; 'chris': 0.26; 'fri,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'entries': 0.27; 'equally': 0.29; "i'm": 0.30; 'subject:/': 0.30; 'probably': 0.31; 'up.': 0.32; 'maybe': 0.33; 'received:google.com': 0.35; 'could': 0.35; 'something': 0.35; "isn't": 0.35; 'but': 0.36; 'possible': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'doing': 0.38; 'why': 0.39; 'sure': 0.39; 'does': 0.39; 'where': 0.40; 'ever': 0.60; 'skip:u 10': 0.61; 'default': 0.61; 'strange': 0.63; 'more': 0.63; 'deeply': 0.64; 'limit': 0.65; 'levels': 0.70; 'jul': 0.72; 'sounds': 0.76; '100': 0.79; '5000+': 0.84; 'careless': 0.84; 'chrisa': 0.84; 'examples.': 0.84; "it'd": 0.84; 'nested,': 0.84; 'recompile': 0.84; 'to:none': 0.91; 'cutting': 0.93; 'safe.': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=ClkilhNS/jR4T9OFjGWa+TIh9Uib2j6e/6Vj/+r2IlQ=; b=T99CkfWOTSXtKra9RnC/hrGLu83aYTXsp6r7pJrXpvuJ03/CFbZJFPk17058CJqLZa gVM02OsP7Y6NPN9oYMUPQjGxcxpScN63oBP3rqTlBBJRAFskhk1u4P+7Vjv1bFYfb99r 828/3BiSFp6+kCPZKDn6jzijR1DDglBeinzTjzYE5LnDaAnVi6AMAaOnANt+4vzPDoF8 icg3fXQrfaRHvH6sWFloUeQKWWB4C+aANC9gJjuM+eaom22Oh2YUtUqE5wtQ4bDYfifd naPjcgRv1RzBi/WLrYLg74EWuGEDRIiuMBgtcLT1jdn/7/tqxlPafktxFhK+yJHHiD57 Yh/Q== MIME-Version: 1.0 X-Received: by 10.50.3.6 with SMTP id 6mr4985019igy.28.1437071382325; Thu, 16 Jul 2015 11:29:42 -0700 (PDT) In-Reply-To: References: <55A3C366.6060602@rece.vub.ac.be> <87fv4r1fre.fsf@jester.gateway.sonic.net> <87bnff1eks.fsf@jester.gateway.sonic.net> <87d1zunctp.fsf@elektro.pacujo.net> <87k2u2eu67.fsf@elektro.pacujo.net> <55A51662.4090007@rece.vub.ac.be> <55A75DE0.1070101@rece.vub.ac.be> <55A7B80B.6090905@rece.vub.ac.be> <55A7C094.7060604@rece.vub.ac.be> Date: Fri, 17 Jul 2015 04:29:42 +1000 Subject: Re: Possibly Pythonic Tail Call Optimization (TCO/TRE) From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1437071389 news.xs4all.nl 2846 [2001:888:2000:d::a6]:47792 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 6061 X-Received-Body-CRC: 419611620 Xref: csiph.com comp.lang.python:93947 On Fri, Jul 17, 2015 at 4:23 AM, Joonas Liik wrote: > On 16 July 2015 at 20:49, Chris Angelico wrote: >> >> This sounds like a denial-of-service attack. If you can state that no >> reasonable document will ever have more than 100 levels of nesting, >> then you can equally state that cutting the parser off with a tidy >> exception if it exceeds 100 levels is safe. >> > This particular example does have that kind of smell.. my bad for > being careless with examples. > > what if its not a ddos tho, maybe its just strange data? > That's why you're allowed to change the default limit either direction. If you're guarding against a DOS, you can crank it down; if you're working with something where 1000 stack entries isn't unreasonable, you can crank it up. I honestly don't know what you'd want to do if 5000+ stack entries isn't enough, but if you're working with something *that* deeply nested, you probably know a lot more about what you're doing than I ever will. Maybe you could recompile CPython with a bigger stack? Give Jython or PyPy a try? No idea. But I'm sure it'd be possible somehow. ChrisA