bug-bison
[Top][All Lists]
Advanced

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

Re: %destructor and stack overflow


From: Hans Aberg
Subject: Re: %destructor and stack overflow
Date: Wed, 27 Apr 2005 23:19:43 +0200

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.
--
  Hans Aberg




reply via email to

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