[antlr-interest] [ANTL 2.7.2][C++] AST destructors eat the whole stack => crash

Ruslan Zasukhin sunshine at public.kherson.ua
Wed Nov 28 15:32:28 PST 2007


Hi All,

We have meet this crash working yet with ANTLR 2.7.2, C++
And I'd like find out if this is known issue,
And if it was fixed in newer versions of ANTLR.

We have try bench SQL commands as
    CREATE TABLE T1 (f1 INT, f2 INT ... f1000 INT)

I.e. Quite long query.

After this query, any next query crashes when we work under MS VISUAL.
Crashes it here:

VSQLPArser::sql()
{
    returnTree = ANTL::null;   <<<<<<<<<


With stack like this:

     Kernel_Win32_Debug.dll!antlr::ASTRef::~ASTRef() Line 23    C++
     Kernel_Win32_Debug.dll!antlr::ASTRef::`scalar deleting destructor'() +
0x2b bytes    C++
     
Kernel_Win32_Debug.dll!antlr::ASTRefCount<antlr::BaseAST>::~ASTRefCount<antl
r::BaseAST>() Line 60 + 0x2d bytes    C++
     Kernel_Win32_Debug.dll!antlr::BaseAST::~BaseAST() Line 29 + 0x1a bytes
C++
     Kernel_Win32_Debug.dll!antlr::CommonAST::~CommonAST() Line 34 + 0x24
bytes    C++
     Kernel_Win32_Debug.dll!antlr::CommonAST::`scalar deleting destructor'()
+ 0x2b bytes    C++

     Kernel_Win32_Debug.dll!antlr::ASTRef::~ASTRef() Line 23 + 0x36 bytes
C++
     Kernel_Win32_Debug.dll!antlr::ASTRef::`scalar deleting destructor'() +
0x2b bytes    C++
     
Kernel_Win32_Debug.dll!antlr::ASTRefCount<antlr::BaseAST>::~ASTRefCount<antl
r::BaseAST>() Line 60 + 0x2d bytes    C++
     Kernel_Win32_Debug.dll!antlr::BaseAST::~BaseAST() Line 29 + 0x1a bytes
C++
     Kernel_Win32_Debug.dll!antlr::CommonAST::~CommonAST() Line 34 + 0x24
bytes    C++
     Kernel_Win32_Debug.dll!antlr::CommonAST::`scalar deleting destructor'()
+ 0x2b bytes    C++

     Kernel_Win32_Debug.dll!antlr::ASTRef::~ASTRef() Line 23 + 0x36 bytes
C++
     Kernel_Win32_Debug.dll!antlr::ASTRef::`scalar deleting destructor'() +
0x2b bytes    C++
     Kernel_Win32_Debug.dll!antlr::ASTRefCount<antlr::AST>::operator=(const
antlr::ASTRefCount<antlr::AST> & other={...}) Line 80 + 0x2d bytes    C++
     Kernel_Win32_Debug.dll!VSQL_Parser::sql() Line 602    C++


It is easy to see, that if we have LONG chain of nodes in the AST tree,
Then current code of destructors do 6 * N calls, where N is number of nodes.

And for 750 nodes, we get crash.
Stack is out ...

So is this known issue?
If yes if it is fixed for ANTLR 3.0 codebase ?
If not  -- please pay attention to it.

It seems to me the best solution ‹ provide own allocator for AST.
And this also gives bonus ­ ability destroy all them in single snap.

I remember few years ago somebody on this list have told he did such
allocator.


-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20071129/f3f07f82/attachment-0001.html 


More information about the antlr-interest mailing list