bison-patches
[Top][All Lists]
Advanced

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

Re: GLR init


From: Paul Eggert
Subject: Re: GLR init
Date: Wed, 20 Jul 2005 14:45:52 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

address@hidden writes:

> At init of glr.c there are _always_ 2 malloc's done,
> but the respons at malloc() failures is this:
>
> situation: first malloc() oke, 2nd one failure,
> result: exit code 139, and a segfault

Thanks for reporting that.

> [would merge yyinitGLRStack and yyinitStateSet]

Yes, that might make sense, but I'd like Paul Hilfinger's opinion.
In the meantime I installed this fix:

2005-07-20  Paul Eggert  <address@hidden>

        * data/glr.c (yyreturn): Don't pop stack if yyinitStateSet failed,
        as the stack isn't valid in that case.  Problem reported by
        address@hidden

Index: data/glr.c
===================================================================
RCS file: /cvsroot/bison/bison/data/glr.c,v
retrieving revision 1.105
diff -p -u -r1.105 glr.c
--- data/glr.c  20 Jul 2005 21:06:26 -0000      1.105
+++ data/glr.c  20 Jul 2005 21:41:37 -0000
@@ -2107,17 +2107,21 @@ b4_syncline(address@hidden@], address@hidden@])])dnl
                 yytoken, yylvalp]b4_location_if([, yyllocp])[);
 
   /* Now pop stack until empty, destroying its entries as we go.  */
-  while (yystack.yytops.yystates[0] != NULL)
-    {
-      yyGLRState *yys = yystack.yytops.yystates[0];
-]b4_location_if([[      yystack.yyerror_range[1].yystate.yyloc = 
yys->yyloc;]])[
-      yydestruct ("Error: popping",
-                 yystos[yys->yylrState],
-                 &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
-      yystack.yytops.yystates[0] = yys->yypred;
-      yystack.yynextFree -= 1;
-      yystack.yyspaceLeft += 1;
-    }
+  {
+    yyGLRState** yystates = yystack.yytops.yystates;
+    if (yystates)
+      while (yystates[0])
+       {
+         yyGLRState *yys = yystates[0];
+]b4_location_if([[       yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]]
+)[       yydestruct ("Error: popping",
+                     yystos[yys->yylrState],
+                     &yys->yysemantics.yysval]b4_location_if([, 
&yys->yyloc])[);
+         yystates[0] = yys->yypred;
+         yystack.yynextFree -= 1;
+         yystack.yyspaceLeft += 1;
+       }
+  }
 
   yyfreeGLRStack (&yystack);
   return yyresult;




reply via email to

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