help-bison
[Top][All Lists]
Advanced

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

%destructor and stack overflow


From: Marcus Holland-Moritz
Subject: %destructor and stack overflow
Date: Tue, 26 Apr 2005 22:39:46 +0200

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




reply via email to

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