[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
yyabortlab bug report (and proposed fix)
From: |
Wolfgang Spraul |
Subject: |
yyabortlab bug report (and proposed fix) |
Date: |
Fri, 20 May 2005 13:34:06 -0400 |
User-agent: |
KMail/1.7.1 |
I'm working with bison 2.0 (release).
It generates the following code:
---
yyabortlab:
yydestruct("Error: discarding lookahead", yytoken, &yylval);
yychar = YYEMPTY;
yyresult = 1;
goto yyreturn;
---
One could argue why setting yychar = YYEMPTY is necessary, since the very next
step is returning from the function, but more importantly, I have crashes in
some cases where the lookahead item is destructed twice.
I could fix my crashes by changing the above fragment to:
---
yyabortlab:
if (yychar != YYEOF && yychar != YYEMPTY)
yydestruct("Error: discarding lookahead", yytoken, &yylval);
yychar = YYEMPTY;
yyresult = 1;
goto yyreturn;
---
I do not nearly oversee all bison cases, so I don't want to propose this as a
'bug fix' (maybe it creates new bugs :-)). But my crash is fixed, and my
understanding is that yylval and yytoken _depend_ on yychar (i.e. if yychar
is YYEMPTY, yytoken and yylval are undefined). So we should check yychar
before calling yydestruct() to free the yylval lookahead token.
Regards,
Wolfgang Spraul
- yyabortlab bug report (and proposed fix),
Wolfgang Spraul <=