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: Tue, 26 Apr 2005 23:46:10 +0200

Again, this is probably a question for Paul to answer, who wrote the current C-parser. I thought that the C-parser was dynamic, except when free store runs out, in which case one is toast anyway. What version of Bison are you using? Is it Bison 2.0? If you have disabled parser stack dynamic reallocation, and gets stack overflow, how do you intend to recover. I mean, then the parser cannot handle the input semantics properly anyway.

At 22:39 +0200 2005/04/26, Marcus Holland-Moritz wrote:
Hi,

I've been using bison for the C parser in one of my perl modules for a
couple of years now. (http://search.cpan.org/~mhx/Convert-Binary-C/)

I recently noticed the %destructor feature and it looks as it would solve
a problem that has long been on my todo list. Right now I'm collecting
all objects that I don't reference otherwise in various lists so I can
free them when the parser exits (when it exits normally, the lists are
usually empty). However, maintaining these lists is time-consuming (both
in programming time and execution time).

I've now rewritten my parser to make use of %destructor, and it works
fine generally. The only case where it doesn't work is when a parser
stack overflow is detected. I can see from the generated parser code
that a parser stack overflow error bypasses yydestruct().

My question: Is there a reason why the %destructor code isn't called
upon parser stack overflow?

I don't see a reason, because when the stack overflow is detected,
the whole stack is still valid and even the items about to be pushed
on the stack are valid and known to the parser. So it should at least
be possible to do a correct cleanup of the parser stack.

Thanks,
Marcus

--
One of the most overlooked advantages to computers is...  If they do
foul up, there's no law against whacking them around a little.
                -- Joe Martin


_______________________________________________
address@hidden http://lists.gnu.org/mailman/listinfo/help-bison






reply via email to

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