help-bison
[Top][All Lists]
Advanced

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

Re: Unexpected error due to EOF


From: Panayiotis Karabassis
Subject: Re: Unexpected error due to EOF
Date: Thu, 22 Jul 2010 22:55:25 +0300
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100620 Icedove/3.0.5

On 07/22/2010 01:55 PM, Akim Demaille wrote:
Le 21 juil. 2010 à 23:15, Panayiotis Karabassis a écrit :

Hi!


Well, it turns out it was a missing YYSTYPE definition from the parser file. 
Thus defaulting to int and having yystate accidentally overwritten on updating 
yylval. A difficult bug.

I might be missing something, but I don't understand how this would be 
possible.  How was that happening?
The parser incorrectly thought that yylval was of type int (the default).
The correct type (ASTNode *) was known to the scanner.

The scanner has a line to set yylval to NULL. Apparently yystate follows yylval in memory.

So whenever the lex function was called yylval was set to NULL.
This had the side effect of also setting yystate to 0, because the parser had reserved memory for yylval as sizeof(int) instead of sizeof(ASTNode *).

Thus each time lex was called yystate was set to 0. Which produced the erroneous behavior.

Making the YYSTYPE definition available to the parser caused it to reserve the correct amount of memory for yylval (sizeof(ASTNode *)) thus solving the problem.

I hope I explained it (and understand it) well enough.

Regards,
    Panayiotis



reply via email to

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