bug-bison
[Top][All Lists]
Advanced

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

Re: yyabortlab bug report (and proposed fix)


From: Hans Aberg
Subject: Re: yyabortlab bug report (and proposed fix)
Date: Sat, 21 May 2005 16:06:56 +0200

The code seems to be written throughout, so that yydestruct() must check whether the token is empty, before trying to free it. The question is whether it should be like that.

At 13:34 -0400 2005/05/20, Wolfgang Spraul wrote:
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


--
  Hans Aberg




reply via email to

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