bison-patches
[Top][All Lists]
Advanced

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

Re: %destructor can leak the lookahead


From: Akim Demaille
Subject: Re: %destructor can leak the lookahead
Date: Sat, 4 Sep 2004 13:04:07 +0200


Le 4 sept. 04, à 00:29, Paul Eggert a écrit :

how can you type it...

With a %token declaration, presumably.  You are allowed to say "%token
error 37".  So I guess you'd say "%token <string> error 37".  It might
be useful to have this as an extension, e.g., a variant of YYERROR
that lets you pass a semantic value back.  (But for now let's not
worry about this.  :-)

I didn't mean how you could do that in practice, but really "what could
it really mean, and how could a single typing fit a token such as error
which is used with many different types".  This is what I meant by
"overloaded token".

--- data/yacc.c 2 Sep 2004 14:27:02 -0000 1.65
+++ data/yacc.c 3 Sep 2004 08:57:48 -0000
@@ -1209,6 +1209,9 @@
 | yyabortlab -- YYABORT comes here.  |
 `-----------------------------------*/
 yyabortlab:
+ YY_SYMBOL_PRINT ("Error: discarding lookahead", yytoken, &yylval, &yylloc);
+  yydestruct (yytoken, &yylval]b4_location_if([, &yylloc])[);
+  yychar = YYEMPTY;
   yyresult = 1;
   goto yyreturn;


How do we know that yytoken is valid here, and can be destroyed?
Might it not be the case that yychar == YYEMPTY as we pass yyabortlab?
Similarly for the other parsers.

I don't remember so.  But anyway, extending yydestruct to the other
situations will require to make it robust to this case.

Other than that, I didn't see any problem (except that the other
memory leaks mention above still remain -- do you have time to look
into them as well?).

Yep, I'll address these too.  Next week I guess.





reply via email to

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