[antlr-interest] Obvious memory leak in Antlr3.1.1 C code

Jim Idle jimi at temporal-wave.com
Fri Nov 7 08:26:26 PST 2008


On Fri, 2008-11-07 at 10:45 +0000, merry_winfly at hotmail.com wrote:

> Dear Jimi,


Hi - please use the list to report errors as others may be able to help
you too.


>  
> Thanks for your product of Antlr, which help me a lot.
>  
> But when I use the C code from antlr generator , I find it exist
> obvious memory leak issue.


The released runtimes are tested using valgrind, and while there are not
really enough tests (as I have bemoaned in the past ;-), I currently do
not know of any memory leaks. I known of one person that claimed to be
seeing a small leak from the last invoked rule, but didn't get any
example to trace that. 

Your issue might be as simple as not closing down the parser or tree
parser properly, but I am not sure if I will have time in the next few
days to analyze your issue (though thanks for the code examples etc). In
the meantime, I suggest that you build the runtime with gcc debug mode
turned on, and then rebuild your parser. Choose an input file that
exhibits this behavior then run the program using valgrind with full
memory tracing. This is usually good enough to tell you where the memory
is going. If you see that it is an ANTLR memory structure, and having
checked the example drivers, you feel that you are closing down
everything correctly, then send me the valgrind output. If it is not an
ANTLR issue, then please also let us know here so that I don't go on
later to try and track down a problem that does not exist.

I have a reported issue with string factories, whereby the move to use
malloc rather than calloc seems to have caused a shutdown issue in some
cases. I will be fixing the known bugs today, so you can always try the
latest source (look for a group announcement).

Assuming I get through all the bugs today (there are not very many), and
catch up with Java development, then I will try and have a look at your
code for you.

Jim

>  
> I have searched wiki topic, in this version, no obvirous memory leak
> exist.
>  
> Could you help me to solve this? (I'm hurry for this code, thanks a
> lot!)
>  
> I list the information and attachment includes all code about it (g
> file, all test C file ):
>  
> Platform: RedHat Enterprise 5 Server, virtual machine.
> GCC version: 4.1.1
> Antlr Version: 3.1.1
>  
> I use following command to generate C code from PLSQLpredigestParser.g
>  
> java -cp antlr-3.1.1.jar -Xmx256M org.antlr.Tool -Xconversiontimeout
> 10000 PLSQLpredigestParser.g
>  
>  
> And use following command to compile:
>  
> gcc -c  -I. -w -g  -c *.c
> g++ -c -w -g -I . -c *.cpp
> g++   -w -g -I.   -o treeMemory *.o 
>  
>  
> I don't know if it is enough information to trace this problem, but if
> you want to know any more information, pls freely contact me with this
> E-mail.
>  
> Thanks a lot.
>  
>  
> Best Regards
> Winfly Lin
> 
> 
> ______________________________________________________________________
> Get news, entertainment and everything you care about at Live.com.
> Check it out!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081107/c69a493b/attachment.html 


More information about the antlr-interest mailing list