Using bison with wrapped malloc/free and testing
it doing intentionally unusual things with the
possible settings in bison generated yacc parser
did not found a segfault situation but came across:
/* set initial size of parser stack */
#define YYINITDEPTH 0
Then running a parser returned yyparse() status 1.
in the output:
Starting parse
Stack size increased to 0
Stack now 0
output in own routines:
parser YYSTACK_ALLOC_MAXIMUM is set -1 and YYSIZE_MAXIMUM is set -1
YYMAXDEPTH is set 10000 YYINITDEPTH is set 0
bison malloc 0x62e460 for 30 bytes
bison free 0x62e460
running a parser with YYINITDEPTH 1 just runs fine.
it looks that setting YYMAXDEPTH < YYINITDEPTH there is no problem.
it is easy to fix in yyparse():
yystacksize = YYINITDEPTH;
if (!yystacksize) { yystacksize = 1; }
YYDPRINTF ((stderr, "Starting parse\n"));
Thanks.