[antlr-interest] A bug of ANTLR3.1.1 C Target

Ronghui Yu stoneyrh at gmail.com
Sat Oct 11 08:44:45 PDT 2008


Hi, Jim,

I just switched to ANTLR3.1.1 from 3.1, and I found an error I never saw
before.
Here is the stack information:

(gdb) c
Continuing.
the statement being parsed is->create something

Program received signal SIGSEGV, Segmentation fault.
0x00e15b54 in getText (token=0x9fa2070) at src/antlr3commontoken.c:346
346 token->tokText.text = token->strFactory->newStr8(token->strFactory,
(pANTLR3_UINT8)"<EOF>");
Current language: auto; currently c
(gdb) where
#0 0x00e15b54 in getText (token=0x9fa2070) at src/antlr3commontoken.c:346
#1 0x00fcedb8 in tokenEquals (token=0x9fa2070, word=0x602f002 ";") at
Common/LMSQLParser/common/Util.cpp:29
#2 0x05af26fe in sql_statement (ctx=0x9fb43a8) at
Common/LMSQLParser/oracle/PLSQLParser.c:180772
#3 0x05af23e3 in start (ctx=0x9fb43a8, ptr=0xbff734a0) at
Common/LMSQLParser/oracle/PLSQLParser.c:180656
...
(gdb) print *token
$1 = {type = 4294967295, factoryMade = 1, strFactory = 0x0, line = 2,
lineStart = 0x0, charPosition = -1, channel = 0, input = 0x0,
index = 0, start = 4, stop = 4, textState = 0, tokText = {chars = 0x0,
text = 0x0}, user1 = 0, user2 = 0, user3 = 0, custom = 0x0,
freeCustom = 0, getText = 0xe15aa0 <getText>, setText = 0xe15ba0
<setText>, setText8 = 0xe15b60 <setText8>, getType = 0xe15bc0 <getType>,
setType = 0xe15bd0 <setType>, getLine = 0xe15be0 <getLine>, setLine =
0xe15bf0 <setLine>,
getCharPositionInLine = 0xe15c00 <getCharPositionInLine>,
setCharPositionInLine = 0xe15c10 <setCharPositionInLine>,
getChannel = 0xe15c20 <getChannel>, setChannel = 0xe15c30 <setChannel>,
getTokenIndex = 0xe15c40 <getTokenIndex>,
setTokenIndex = 0xe15c50 <setTokenIndex>, getStartIndex = 0xe15c60
<getStartIndex>, setStartIndex = 0xe15c80 <setStartIndex>,
getStopIndex = 0xe15c90 <getStopIndex>, setStopIndex = 0xe15ca0
<setStopIndex>, toString = 0xe15cb0 <toString>}
(gdb)

When parsing an invalid statement, our parser crashes with this error.

The function tokenEquals above is called as tokenEquals(LT(1),";") in
semantic predicate action, within which, the token->getText(token) is
called to retrieve the text string, then error happens.




-- 

Regards

Ronghui Yu


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


More information about the antlr-interest mailing list