From: Jeff Law <law@redhat.com>
To: Jason Merrill <jason@redhat.com>, Jakub Jelinek <jakub@redhat.com>
Cc: Michael Matz <matz@suse.de>, Nick Clifton <nickc@redhat.com>,
Ian Lance Taylor <iant@google.com>,
"H.J. Lu" <hjl.tools@gmail.com>, Pedro Alves <palves@redhat.com>,
Richard Biener <richard.guenther@gmail.com>,
Scott Gayou <sgayou@redhat.com>, Tom Tromey <tom@tromey.com>,
gcc-patches List <gcc-patches@gcc.gnu.org>,
Binutils <binutils@sourceware.org>
Subject: Re: [PATCH] Set DEMANGLE_RECURSION_LIMIT to 1536
Date: Tue, 11 Dec 2018 00:33:00 -0000 [thread overview]
Message-ID: <2b97a775-ed9a-9bd2-e574-52b679f464c7@redhat.com> (raw)
In-Reply-To: <CADzB+2nX8UO94EjRiSegxFXBKwb7qmYLLpSjbJmXkZNo20M7Lg@mail.gmail.com>
On 12/10/18 8:34 AM, Jason Merrill wrote:
> On Mon, Dec 10, 2018 at 10:10 AM Jakub Jelinek <jakub@redhat.com> wrote:
>> On Mon, Dec 10, 2018 at 02:52:39PM +0000, Michael Matz wrote:
>>> On Fri, 7 Dec 2018, H.J. Lu wrote:
>>>
>>>>>> On Thu, Dec 6, 2018 at 3:12 AM Nick Clifton <nickc@redhat.com> wrote:
>>>>>>>
>>>>>>> Is the patch OK with you ?
>>>>>>
>>>>>
>>>>> This caused:
>>>>>
>>>>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88409
>>>>>
>>>>
>>>> Here is the fix. OK for trunk?
>>>
>>> I think this points toward the limit being _much_ too low. With template
>>> meta programming you easily get these mangled names, it's not even a
>>> particularly long one. But I'm wondering a bit, without tracing the
>>> demangler, just looking at the symbol name and demangled result I don't
>>> readily see where the depth of recursion really is more than 1024, are
>>> there perhaps some recursion_level-- statements skipped?
>>
>> That is because the recursion_level limit isn't hit in this case at all (far
>> from it).
>>
>> What breaks it is this:
>>
>> /* PR 87675 - Check for a mangled string that is so long
>> that we do not have enough stack space to demangle it. */
>> if (((options & DMGL_NO_RECURSE_LIMIT) == 0)
>> /* This check is a bit arbitrary, since what we really want to do is to
>> compare the sizes of the di.comps and di.subs arrays against the
>> amount of stack space remaining. But there is no portable way to do
>> this, so instead we use the recursion limit as a guide to the maximum
>> size of the arrays. */
>> && (unsigned long) di.num_comps > DEMANGLE_RECURSION_LIMIT)
>> {
>> /* FIXME: We need a way to indicate that a stack limit has been reached. */
>> return 0;
>> }
>
>> where di.num_comps is just strlen (mangled) * 2. Without any analysis
>> whatsoever, bumping the "recursion" limit will just mean we can process 1.5
>> times long names. Either we need more precise analysis on what we are
>> looking for (how big arrays we'll need) or it needs to be an independent
>> limit and certainly should allow say 10KB symbols too if they are
>> reasonable.
>
> If the problem is alloca, we could avoid using alloca if the size
> passes a threshold. Perhaps even use a better data structure than a
> preallocated array based on a guess about the number of components...
Actually I would strongly suggest avoiding alloca completely. This
isn't particularly performance sensitive code and alloca can be abused
in all kinds of interesting ways.
jeff
next prev parent reply other threads:[~2018-12-11 0:33 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-30 8:38 RFA/RFC: Add stack recursion limit to libiberty's demangler Nick Clifton
2018-11-30 8:42 ` Jakub Jelinek
2018-11-30 10:27 ` Nick Clifton
2018-11-30 13:46 ` Michael Matz
2018-11-30 14:57 ` Ian Lance Taylor
2018-12-02 0:49 ` Cary Coutant
2018-12-03 14:53 ` Nick Clifton
2018-12-03 22:00 ` Joseph Myers
2018-11-30 13:56 ` Ian Lance Taylor
2018-11-30 14:03 ` Jakub Jelinek
2018-11-30 17:41 ` RFA/RFC: Add stack recursion limit to libiberty's demangler [v3] Nick Clifton
2018-11-30 17:49 ` Jakub Jelinek
2018-11-30 18:19 ` Pedro Alves
2018-12-03 10:28 ` Richard Biener
2018-12-03 14:45 ` Nick Clifton
2018-12-03 18:49 ` Ian Lance Taylor via gcc-patches
2018-12-04 14:00 ` RFA/RFC: Add stack recursion limit to libiberty's demangler [v4] Nick Clifton
2018-12-04 15:02 ` Pedro Alves
2018-12-04 16:57 ` RFA/RFC: Add stack recursion limit to libiberty's demangler [v5] Nick Clifton
2018-12-04 17:08 ` Pedro Alves
2018-12-06 11:12 ` Nick Clifton
2018-12-06 18:04 ` Ian Lance Taylor via gcc-patches
2018-12-07 16:17 ` H.J. Lu
2018-12-07 16:25 ` [PATCH] Set DEMANGLE_RECURSION_LIMIT to 1536 H.J. Lu
2018-12-10 14:52 ` Michael Matz
2018-12-10 15:10 ` Jakub Jelinek
2018-12-10 15:34 ` Jason Merrill
2018-12-11 0:33 ` Jeff Law [this message]
2018-12-11 6:58 ` Jakub Jelinek
2018-12-11 11:05 ` Pedro Alves
2018-12-11 14:26 ` Ian Lance Taylor via gcc-patches
2018-12-11 15:07 ` Pedro Alves
2018-12-11 10:34 ` Pedro Alves
2018-12-10 15:12 ` Nick Clifton
2018-12-10 15:18 ` Jakub Jelinek
2018-12-10 15:26 ` Nick Clifton
2018-12-10 15:35 ` Jakub Jelinek
2018-12-10 18:20 ` Ian Lance Taylor via gcc-patches
2018-12-10 18:55 ` Jakub Jelinek
2018-12-10 23:47 ` Jason Merrill
2018-12-10 15:18 ` David Malcolm
2018-12-10 15:31 ` Nick Clifton
2018-12-06 16:14 ` RFA/RFC: Add stack recursion limit to libiberty's demangler [v5] Jason Merrill
2018-12-06 21:22 ` RFC: libiberty PATCH to disable demangling of ancient mangling schemes Jason Merrill
2018-12-07 10:27 ` Nick Clifton
2018-12-07 10:40 ` Jakub Jelinek
2018-12-07 16:11 ` Pedro Alves
2018-12-07 17:49 ` Tom Tromey
2018-12-07 21:00 ` Jason Merrill
2018-12-14 22:39 ` Jason Merrill
2018-12-16 4:50 ` Simon Marchi
2018-12-07 16:28 ` Nick Clifton
2018-12-07 11:37 ` Richard Biener
2018-12-07 15:49 ` Jason Merrill
2018-12-10 1:04 ` Eric Gallager
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2b97a775-ed9a-9bd2-e574-52b679f464c7@redhat.com \
--to=law@redhat.com \
--cc=binutils@sourceware.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=hjl.tools@gmail.com \
--cc=iant@google.com \
--cc=jakub@redhat.com \
--cc=jason@redhat.com \
--cc=matz@suse.de \
--cc=nickc@redhat.com \
--cc=palves@redhat.com \
--cc=richard.guenther@gmail.com \
--cc=sgayou@redhat.com \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).