bison-2.1 fails to detect stack overflow in GLR parser. Namely,
`yyglrShiftDefer' assumes that there are 2 free stack slots, and
check is done only in `yyaddDeferredAction'. However, `yyexpandGLRStack'
only guaranteed increase by one. The problem appered in GNU Pascal,
causing segmentation faults due to parser stack overflow. I do not
include a testcase since GNU Pascal parser is large.

The following patch fixed the problem:

--- bison-2.1/data/glr.c.bb     2006-02-25 13:30:31.182883336 +0100
+++ bison-2.1/data/glr.c        2006-02-25 13:32:29.239935936 +0100
@@ -1089,7 +1089,7 @@
   size_t yysize, yynewSize;
   size_t yyn;
   yysize = yystack->yynextFree - yystack->yyitems;
-  if (YYMAXDEPTH <= yysize)
+  if (YYMAXDEPTH < yysize + YYHEADROOM)
     yyMemoryExhausted (yystack);
   yynewSize = 2*yysize;
   if (YYMAXDEPTH < yynewSize)

-- 
                              Waldek Hebisch
[EMAIL PROTECTED] 


Reply via email to