This is the mail archive of the
mailing list for the GCC project.
Re: RFA/RFC: Add stack recursion limit to libiberty's demangler
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Cary Coutant <ccoutant at gmail dot com>
- Cc: Nick Clifton <nickc at redhat dot com>, Jakub Jelinek <jakub at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Binutils <binutils at sourceware dot org>, <sgayou at redhat dot com>, Jason Merrill <jason at redhat dot com>, Michael Matz <matz at suse dot de>
- Date: Mon, 3 Dec 2018 22:00:28 +0000
- Subject: Re: RFA/RFC: Add stack recursion limit to libiberty's demangler
- References: <email@example.com> <20181130084211.GX12380@tucnak> <firstname.lastname@example.org> <alpine.LSU.email@example.com> <firstname.lastname@example.org> <CAJimCsES7ctTGHWRDHAdEEiwiY3nWCod5xdo4MSSAGDCmk53qg@mail.gmail.com>
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
Joseph S. Myers