Hi all,

I am using bison 2.6.5 and discovered that the GLR parser leaks memory when 
exceptions are used. I used the glr.cc skeleton and want to throw an exception 
after a certain amount of syntax errors. The memory is leaked by the glr-stack 
itself and not by any of my semantic values (they don't need destruction).

This is no show-stopper for me but it would be nice if the generated parser 
were exception safe. I attached some valgrind output that should indicate 
where the memory is leaked. Also note that if I switch to the larl1.cc 
skeleton, no memory is leaked. (But I cannot parse some input then.)

If you need a minimalistic example, I can create one. Just tell me.

Regards, Roland

==32132== HEAP SUMMARY:
==32132==     in use at exit: 14,583 bytes in 4 blocks
==32132==   total heap usage: 20,471 allocs, 20,467 frees, 4,663,529 bytes allocated
==32132== 
==32132== 16 bytes in 1 blocks are definitely lost in loss record 1 of 4
==32132==    at 0x4C244E8: malloc (vg_replace_malloc.c:236)
==32132==    by 0x563133: yyinitStateSet(yyGLRStateSet*) (grammar.cc:2702)
==32132==    by 0x557722: yyinitGLRStack(yyGLRStack*, unsigned long) (grammar.cc:2732)
==32132==    by 0x556B26: Grammar_parse(Grammar::parser&, State*) (grammar.cc:3903)
==32132==    by 0x559418: Grammar::parser::parse() (grammar.cc:4233)
==32132==    ...
==32132== 
==32132== 39 bytes in 1 blocks are definitely lost in loss record 2 of 4
==32132==    at 0x4C244E8: malloc (vg_replace_malloc.c:236)
==32132==    by 0x557C9E: yyreportSyntaxError(yyGLRStack*, Grammar::parser&, State*) (grammar.cc:3730)
==32132==    by 0x556F50: Grammar_parse(Grammar::parser&, State*) (grammar.cc:3977)
==32132==    by 0x559418: Grammar::parser::parse() (grammar.cc:4233)
==32132==    ...
==32132== 
==32132== 14,528 (128 direct, 14,400 indirect) bytes in 1 blocks are definitely lost in loss record 4 of 4
==32132==    at 0x4C244E8: malloc (vg_replace_malloc.c:236)
==32132==    by 0x5630F5: yyinitStateSet(yyGLRStateSet*) (grammar.cc:2697)
==32132==    by 0x557722: yyinitGLRStack(yyGLRStack*, unsigned long) (grammar.cc:2732)
==32132==    by 0x556B26: Grammar_parse(Grammar::parser&, State*) (grammar.cc:3903)
==32132==    by 0x559418: Grammar::parser::parse() (grammar.cc:4233)
==32132==    ...
==32132== 
==32132== LEAK SUMMARY:
==32132==    definitely lost: 183 bytes in 3 blocks
==32132==    indirectly lost: 14,400 bytes in 1 blocks
==32132==      possibly lost: 0 bytes in 0 blocks
==32132==    still reachable: 0 bytes in 0 blocks
==32132==         suppressed: 0 bytes in 0 blocks
==32132== 
==32132== For counts of detected and suppressed errors, rerun with: -v
==32132== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 4 from 4)

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to