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 _______________________________________________ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison