This is the mail archive of the
gcc-patches@gcc.gnu.org
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: <87muprdko7.fsf@redhat.com> <20181130084211.GX12380@tucnak> <173817ca-0aa0-e1a2-6725-37e079ead545@redhat.com> <alpine.LSU.2.21.1811301331360.5354@wotan.suse.de> <m35zwe4nqg.fsf@pepe.airs.com> <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
the parsers.)
--
Joseph S. Myers
joseph@codesourcery.com