help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: %destructor and stack overflow


From: Marcus Holland-Moritz
Subject: Re: %destructor and stack overflow
Date: Thu, 28 Apr 2005 22:47:35 +0200

On 2005-04-27, at 23:19:43 +0200, Hans Aberg wrote:

> At 21:20 +0200 2005/04/27, Marcus Holland-Moritz wrote:
> >%destructor looks like it has the ability to be this "something
> >better", but IMO it currently isn't as good as it could be (i.e.
> >it is worse than my solution with regard to potential memory
> >leaks arising from parser stack overflow).
> 
> The intent of %destructor is to help cleanup during error stack 
> unwinding. If one can somehow make a stack overflow cause an error, 
> which in its turns causes the stack to unwind, then the cleanup would 
> take place via %destructor.
> 
> >I think #define'ing YYMAXDEPTH to MAXINT (or any other XXL number)
> >isn't a good idea. I know that no sane code requires the parser
> >stack to be as large as 1000 items. So with YYMAXDEPTH = 10000
> >I'm clearly on the safe side. And I prefer to have an error at a
> >well-defined boundary rather than some part of the application
> >running out of "real" memory when passed illegal input.
> 
> So if you get a stack overflow error, what do you want to happen? 
> Clearly, the parser must be taken down. You want it then to done so 
> that stack cleanup takes place. Right? Possibly, the same cleanup 
> actions as those in %destructor should be used.

Yes, that's exactly what I'm talking about.

When the parser detects a stack overflow, it should call
the cleanup actions defined via %destructor for all symbols
on the stack (and the symbol causing the overflow) before
it returns.

Marcus




reply via email to

[Prev in Thread] Current Thread [Next in Thread]