helpbison - Support: sr #108481, Assertion `!yytname_' failed.

 
 

sr #108481: Assertion `!yytname_' failed.

Submitted by:  None
Submitted on:  Thu 23 Jan 2014 04:30:53 PM UTC  
 
Category: NonePriority: 5 - Normal
Severity: 3 - NormalStatus: None
Privacy: PublicAssigned to: None
Originator Email: -unavailable-Open/Closed: Open
Operating System: GNU/Linux

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 27 May 2014 12:11:01 PM UTC, comment #3:

Never be lazy :-(

Since the patch is only 3 line long, I thought it would be correct to put it in my mail... Here it is as attachment.

(file #31446)

Michel DHOOGE <mdhooge>
Tue 27 May 2014 12:08:03 PM UTC, comment #2:

I created a patch that permanently solves the problem. But I'm not sure this is the best option. I think an intermediate method that avoid to duplicate the destruction code would be much better.

      • /home/michel/dev_3rd/bison/data/lalr1.cc 2014-05-25 12:14:08.268061947 +0200

--- /usr/share/bison/lalr1.cc 2014-05-27 14:00:01.202047507 +0200

                              • b4_dollar_popdef])[]dnl
      • 891,896 ****

--- 891,900 ----
{
yy_destroy_ ("Error: discarding", yyla);
yyempty = true;
+
+ // Type destructor.
+ symbol_number_type yytype = yyla.type_get ();
+ ]b4_symbol_variant([[yytype]], [[yyla.value]], [[template destroy]])[
}
}

Michel DHOOGE <mdhooge>
Sun 25 May 2014 06:12:40 PM UTC, comment #1:

Hello,

I tracked this bug down and found a workaround...

In lalr1.cc, the yyerrlab section has the following code:
yy_destroy_ ("Error: discarding", yyla);
yyempty = true;

Unfortunately, this isn't enough to really destroy the semantic_type value of the yyla variable (yy_destroy_ only prints a message). But the yyempty variable is still set to false.

So, when a new token is read, the following lines trigger the assertion of this bug report:
symbol_type yylookahead (yylex ());
yyla.move (yylookahead);

First, I tried to copy the code of basic_symbol<Base>::~basic_symbol directly into the yy_destroy function. But this breaks code that pop the stack.

So my workaround is to copy/paste/adapt the basic_symbol<Base>::~basic_symbol code into the yyerrlab discarding block.

Michel DHOOGE <mdhooge>
Thu 23 Jan 2014 04:30:53 PM UTC, original submission:

Hi all,
I was testing error recovery with bison and I'm getting this assertion here:

/// Instantiate an empty \a T in here.
template <typename T>
T&
build ()
{
YYASSERT (!yytname_);
YYASSERT (sizeof (T) <= S);
yytname_ = typeid (T).name ();
return *new (yyas_<T> ()) T;
}
when using this simple grammar.

%token <char> CHAR "char"
%token <int> NUM "number"
%token SEMICOLON ";"
%token END 0 "end of file"

%%

stms : stms CHAR ";"
| CHAR ";"
| error ";" {yyerrok;}
;

%%

I've used bison 3.0.2 and flex 2.5.37.
I'm attaching all the code I used with this test.

I was expecting two error messages, and in fact I get those messages when I remove the parse.assert definition.

I used g++ *.cpp -o test to compile the code, after bison and flex.

Cheers,
Antonio

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #31446:  lalr1.cc.patch added by mdhooge (526B - text/x-patch)
file #30354:  assert_error.zip added by None (34kB - application/octet-stream - Example to reproduce the problem)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by mdhooge (Posted a comment)
  • -unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 27 May 2014 12:11:01 PM UTCmdhoogeAttached File-=>Added lalr1.cc.patch, #31446
    Thu 23 Jan 2014 04:30:53 PM UTCNoneAttached File-=>Added assert_error.zip, #30354

    Back to the top


    Powered by Savane 3.1-cleanup