From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 81447 invoked by alias); 3 Dec 2018 22:00:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 81296 invoked by uid 89); 3 Dec 2018 22:00:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=occasionally, H*f:sk:m35zwe4, million, gracefully X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Dec 2018 22:00:39 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-01.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1gTwGW-0000xp-5n from joseph_myers@mentor.com ; Mon, 03 Dec 2018 14:00:32 -0800 Received: from digraph.polyomino.org.uk (137.202.0.90) by svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Mon, 3 Dec 2018 22:00:28 +0000 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.90_1) (envelope-from ) id 1gTwGS-00084V-Cz; Mon, 03 Dec 2018 22:00:28 +0000 Date: Mon, 03 Dec 2018 22:00:00 -0000 From: Joseph Myers To: Cary Coutant CC: Nick Clifton , Jakub Jelinek , GCC Patches , Binutils , , Jason Merrill , Michael Matz Subject: Re: RFA/RFC: Add stack recursion limit to libiberty's demangler In-Reply-To: Message-ID: References: <87muprdko7.fsf@redhat.com> <20181130084211.GX12380@tucnak> <173817ca-0aa0-e1a2-6725-37e079ead545@redhat.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-SW-Source: 2018-12/txt/msg00133.txt.bz2 On Sat, 1 Dec 2018, Cary Coutant wrote: > In order to handle arbitrary user input without crashing, perhaps the > demangler should switch from recursive descent parsing to a state > machine, where exhaustion of resources can be handled gracefully. I've wondered if a GCC C/C++ extension could be defined that means "convert this set of mutually recursive functions into a single function with a state machine that allocates the equivalent of the stack manually". But such an extension would certainly be nontrivial to define. (One use for such an extension would be to avoid the GCC bugs that occasionally get reported of the form "expressions with a million nested pairs of parentheses make the compiler segfault", by using it to avoid recursion in the parsers.) -- Joseph S. Myers joseph@codesourcery.com