[antlr-interest] Stack overflow problem with C++

Jörg Hälker jogi1978 at gmx.de
Tue Jul 19 02:55:59 PDT 2005


 
Hi!

I am working with version 2.7.3 but i even tried 2.7.5 with MS VS .NET 2003
version 7.1.3088 under WinXP. It still produces an stack overflow. Have no
idea why... later the day i'm going to install cygwin to see what happens...

Best regards,
Jörg 

> -----Original Message-----
> From: Ric Klaren [mailto:ric.klaren at gmail.com] 
> Sent: Tuesday, July 19, 2005 9:24 AM
> To: Jorg Halker
> Cc: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Stack overflow problem with C++
> 
> On 7/19/05, Jorg Halker <jogi1978 at gmx.de> wrote:
> > If i run the following code i get a stack overflow error:
> > 
> > ****************************************
> > #include <antlr/CommonAST.hpp>
> > 
> > using namespace antlr;
> > using namespace std;
> > 
> > int main(int argc, char * * argv)
> > {
> >         RefCommonAST first = RefCommonAST( new CommonAST());
> >         RefCommonAST current = first;
> >         for (unsigned int counter = 0; counter < 9000; ++counter)
> >         {
> >                 current->setNextSibling(RefAST( new CommonAST()));
> >                 current = current->getNextSibling();
> >         }
> > }
> > ****************************************
> > 
> > It looks like a problem with the destructor of CommonAST or 
> its base 
> > classes. The error occours if 'first' runs out of the scope.
> > If i create a parser that parses an input file into the same AST 
> > scheme, everything works fine. But if i create a copy of 
> the AST from 
> > the parser i run into the same problem.
> > 
> > What's wrong? The code snippet should not produce an stack overflow 
> > error, am i right?
> 
> Nope it shouldn't (and it doesn't on a number of machines I have acces
> to) Which leads to the question:  What antlr version? What 
> OS? What compiler?
> 
> Cheers,
> 
> Ric
> 



More information about the antlr-interest mailing list