Re: bison and valgrind



Allan Adler <ara@xxxxxxxxxxxxxxxxxxxx> writes:

I haven't actually tested the parser with valgrind. I'll do that tomorrow.
I just consider it extremely likely that it will be leaky.

I did it. As I expected the parser is leaky. Let's call the data type a gleep.
When the action says {$$ = cat_gleep($1,$2);}
thereby causing a new gleep to be allocated, I found that bison doesn't
complain if I change it to something like:
{$$ = cat_gleep($1,$2);
free_gleep(&$1);
free_gleep(&$2);
}

That probably means that I do have a little bit of control over leaks.

not.. Assuming I can do that, what I am then worried about is that the place
where I have to modify the parser to plug the leak will be part of the boiler
plate code that bison uses, and therefore is not really accessible as part of
the normal use of bison and flex. In particular, if I modify the .y file, I
will also have to modify by hand the file that bison produces every time I do
so. There are worse fates, but if there is a way to avoid this particular
fate, I'd like to know about it.

When I ran valgrind, I found that there were leaks in the routines
yy_flex_alloc and yy_create_buffer. I'm less certain about how to deal
with these, since it appears that they come from the boiler plate of flex
(I don't really know for sure).
--
Ignorantly,
Allan Adler <ara@xxxxxxxxxxxxxxxxxxxx>
* Disclaimer: I am a guest and *not* a member of the MIT CSAIL. My actions and
* comments do not reflect in any way on MIT. Also, I am nowhere near Boston.
.



Relevant Pages

  • Csup cvsmode build discussion
    ... lex and yacc files that I would like to discuss. ... I implemented the RCS parser required to operate on RCS files ... I've been compiling the parser and tokenizer with the help of bison ... Now, the base system already have flex, but the flex version in base is heavily ...
    (freebsd-hackers)
  • Re: Csup cvsmode build discussion
    ... lex and yacc files that I would like to discuss. ... I implemented the RCS parser required to operate on RCS files ... I've been compiling the parser and tokenizer with the help of bison ... Now, the base system already have flex, but the flex version in base is heavily ...
    (freebsd-hackers)
  • Re: Flex&Bison: how to write a parser for this grammar?
    ... bison? ... it's better to rely on a parser generator than on hand-written ... a yacc parser will be simpler if the grammar is suitable so ... need for flex start conditions there as I feared there might be. ...
    (comp.programming)
  • ANNOUNCE: DJGPP port of GNU bison 2.1 uploaded.
    ... This is a port of GNU Bison 2.1 to MSDOS/DJGPP. ... Bison is a Yacc compatible parser generator. ... Bison 2.1 is mostly a bug fix version since the last official release ... If LFN support is available or not is determinated at run time. ...
    (comp.os.msdos.djgpp)
  • Re: GPL vs non-GPL device drivers
    ... non-derivative work - Bison was not required, but was used as a mean of ... When you reach a large scale parser, such as one that meets all ... If Bison and Flex were offered under the "bare" GPL, ... claiming license under the GPL with regard to your parser. ...
    (Linux-Kernel)