From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 129529 invoked by alias); 3 Dec 2018 10:28:12 -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 128920 invoked by uid 89); 3 Dec 2018 10:28:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=counters, libibertys, overflows, libiberty's X-HELO: mail-lj1-f175.google.com Received: from mail-lj1-f175.google.com (HELO mail-lj1-f175.google.com) (209.85.208.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Dec 2018 10:28:09 +0000 Received: by mail-lj1-f175.google.com with SMTP id g11-v6so10838067ljk.3; Mon, 03 Dec 2018 02:28:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Jruj2kjzhsicf4H6BRHRt9sjPKA1egneWr9fgWzvV/4=; b=QH33PVuLVQ/x4TwhsWo93PnCvGZ1fRuNPx8bteFeLuTfg/UBqnQqW4Tu0PAi+moV9c DlxBx69frKtes0PuCjLepopdjidjyZ2G3PaQOBblwnPZgaXb0IhL2ol0V/4cE/9EtuHk CeyXOzm1f7BWLtrNfVdEzI9xTXgjjtYWtpX13Ywt1vvwPSFaDPbPTc0tWYWgOl3WblHX 3almZjJ77iPE45gyaPVCqI02nJoQ58xr47Lw8ENmDmDAYmu/5eJXGORuMsJhj8DS2Pnw UzZQ1XiYx+b0zfpBajeVtnHGF/XYEZRnXY0pqwpoiPn53pOFk01M/Dyjj843mnfXlOIl YR9Q== MIME-Version: 1.0 References: <87muprdko7.fsf@redhat.com> <20181130084211.GX12380@tucnak> <173817ca-0aa0-e1a2-6725-37e079ead545@redhat.com> <20181130140330.GA12380@tucnak> In-Reply-To: From: Richard Biener Date: Mon, 03 Dec 2018 10:28:00 -0000 Message-ID: Subject: Re: RFA/RFC: Add stack recursion limit to libiberty's demangler [v3] To: Nick Clifton Cc: Jakub Jelinek , matz@gcc.gnu.org, sgayou@redhat.com, Ian Lance Taylor , Pedro Alves , tom@tromey.com, GCC Patches , Binutils , Jason Merrill Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-12/txt/msg00065.txt.bz2 On Fri, Nov 30, 2018 at 6:41 PM Nick Clifton wrote: > > Hi Guys, > > >> I think it would be fine to have a large fixed limit plus a flag to > >> disable the limit. > > Great - in which case please may I present version 3 of the patch. In > this version: > > * The cplus_demangle_set_recursion_limit() function has been removed > and instead a new constant - DEMANGLE_RECURSION_LIMIT - is defined in > demangle.h. > > * The recursion counters in cp-demangle.c have been merged into one > counter, now contained in the d_info structure. > > * In cplus-dem.c the recursion counter has been moved into the work > structure. > > * The description of the DMGL_RECURSE_LIMIT option in demangle.h has > been enhanced to add a note that if the option is not used, then > bug reports about stack overflows in the demangler will be rejected. Shouldn't we make it fool-proof by instead introducing a DMGL_NO_RECURSION_LIMIT flag and when not set default to limiting recursion? > * The binutils patch has been updated to reflect these changes. The > addr2line, cxxfilt, nm and objdump programs now have two new options > --recurse-limit and --no-recurse-limit, with --recurse-limit being > the default. The documentation is updated to describe these options > and to also add a note about bug reports being rejected if > --no-recurse-limit is used. > > What do you think, is this version acceptable ? > > Cheers > Nick > > libiberty/ChangeLog > 2018-11-29 Nick Clifton > > PR 87681 > PR 87675 > PR 87636 > PR 87335 > * cp-demangle.h (struct d_info): Add recursion_limit field. > * cp-demangle.c (d_function_type): If the recursion limit is > enabled and reached, return with a failure result. > (d_demangle_callback): If the recursion limit is enabled, check > for a mangled string that is so long that there is not enough > stack space for the local arrays. > * cplus-dem.c (struct work): Add recursion_level field. > (demangle_nested_args): If the recursion limit is enabled and > reached, return with a failure result. > > include/ChangeLog > 2018-11-29 Nick Clifton > > * demangle.h (DMGL_RECURSE_LIMIT): Define. > (DEMANGLE_RECURSION_LIMIT): Prototype. > > binutils/ChangeLog > 2018-11-29 Nick Clifton > > * addr2line.c (demangle_flags): New static variable. > (long_options): Add --recurse-limit and --no-recurse-limit. > (translate_address): Pass demangle_flags to bfd_demangle. > (main): Handle --recurse-limit and --no-recurse-limit options. > * cxxfilt.c (flags): Add DMGL_RECURSE_LIMIT. > (long_options): Add --recurse-limit and --no-recurse-limit. > (main): Handle new options. > * dlltool.c (gen_def_file): Include DMGL_RECURSE_LIMIT in flags > passed to cplus_demangle. > * nm.c (demangle_flags): New static variable. > (long_options): Add --recurse-limit and --no-recurse-limit. > (main): Handle new options. > * objdump.c (demangle_flags): New static variable. > (usage): Add --recurse-limit and --no-recurse-limit. > (long_options): Likewise. > (objdump_print_symname): Pass demangle_flags to bfd_demangle. > (disassemble_section): Likewise. > (dump_dymbols): Likewise. > (main): Handle new options. > * prdbg.c (demangle_flags): New static variable. > (tg_variable): Pass demangle_flags to demangler. > (tg_start_function): Likewise. > * stabs.c (demangle_flags): New static variable. > (stab_demangle_template): Pass demangle_flags to demangler. > (stab_demangle_v3_argtypes): Likewise. > (stab_demangle_v3_arg): Likewise. > * doc/binutuls.texi: Document new command line options. > * NEWS: Mention the new feature. > * testsuite/config/default.exp (CXXFILT): Define if not already > defined. > (CXXFILTFLAGS): Likewise. > * testsuite/binutils-all/cxxfilt.exp: New file. Runs a few > simple tests of the cxxfilt program.