bug-bison
[Top][All Lists]
Advanced

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

Possibly Memory Leak Bug - yypstate_delete


From: Brandon Lucia
Subject: Possibly Memory Leak Bug - yypstate_delete
Date: Fri, 27 Jul 2007 12:25:17 -0700

hello all,

I've been using the push_parse features in 2.3a+ HEAD from cvs and I think
I've discovered a memory leak.


First, I set things up

%pure-parser %push-parser
#define YYINITDEPTH 1 //or whatever small value you like

//I've allocated a yypstate using
yypstate * yyps =  yypstate_new();

//then i do a series of push_parses.  These invariably cause the stack to
grow.
for(...){
     YYSTYPE yylval;
     yypush_parse(yyps,some_character,&yylval);
}

//when i'm finished with calls to push_parse, I call

yypstate_delete(yyps);


but when i run this little program from within valgrind, it tells me that
i'm losing YYINITDEPTH bytes.  if after I call yypstate_delete(yyps), i call

free(yyss);

(and here yyss expands to yyps->yyss, since yyss is defined that way in the
gen'd code)

then everything is good, and there is no leak.  Now I'm not familiar enough
with the skeletons,or with m4 or with the bison source to patch this, but it
is reproducible with lots of different grammars and cases (i've tried a
few), and seems easy enough to fix.  It seems that just calling free on yyps
isn't enough in yypstate_delete().  Has any else seen this/ got anyideas as
to how to handle this safely?

Thanks,
-Brandon


reply via email to

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