bison and valgrind
- From: Allan Adler <ara@xxxxxxxxxxxxxxxxxxxx>
- Date: 29 Mar 2007 01:19:27 -0500
I've made some progress and have managed to use bison and flex to write
some simple parsers. The types that they return are complicated data
structures. Before I wrote the parser, the routines I wrote for working
with these data structures were very carefully tested to avoid memory
leaks. One of the things I did to avoid leaks was to use valgrind.
What I'm worried about is that the parser might have a lot of leaks.
The reason I think it is vulnerable to that is that in the actions
I invoke routines that return the various data structures but I don't
know of any logical place to call the routines I use to free those
data structures. That's because I don't know enough about the workings
of the parsers produced by bison and flex.
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.
When I do run it through valgrind, and if I do find the expected leak, then
maybe I can figure out how to modify the parser to plug the leak, and maybe
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.
So, that's the question: how to deal with memory leaks in parsers generated
by bison and flex?
I'm doing this on an old PC running RedHat 7.1 Linux.
--
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.
.
- Follow-Ups:
- Re: bison and valgrind
- From: Allan Adler
- Re: bison and valgrind
- From: Rob Thorpe
- Re: bison and valgrind
- Prev by Date: Re: implementation note for scapegoat tree
- Next by Date: [ANN] Spring 2007 Issue of Methods & Tools
- Previous by thread: implementation note for scapegoat tree
- Next by thread: Re: bison and valgrind
- Index(es):
Relevant Pages
|