bug-libmatheval
[Top][All Lists]
Advanced

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

[bug-libmatheval] Memory leak detected by valgrind in libmatheval-1.1.11


From: Sarl APIFEN
Subject: [bug-libmatheval] Memory leak detected by valgrind in libmatheval-1.1.11
Date: Fri, 10 Oct 2014 20:48:05 +0200 (CEST)

Hello,

I'm running my program with valgrind memcheck, and this puts into light a 
memory link in libmatheval-1.1.11.
I'm using valgrind with the following options:
valgrind --verbose --track-fds=yes --tool=memcheck --leak-check=full 
--show-reachable=yes  my_binary and params

my_binary is calling the following code a different number of time (simplified 
code, hope I didn't make it too simple as I haven't tested it as below):
char * my_func(char * my_equation) {
  void * evalHdl;
  char **names;
  int res;

  evalHdl = evaluator_create(my_equation);
  if (evalHdl == NULL) {
    /* do a trace log */
    return NULL;
  }
  evaluator_get_variables(evalHdl, &names, &res);
  /* do a trace log */
  evaluator_destroy(evalHdl);
  return my_equation;
}

Here are the valgrind leak reports (always 3):

==24573== 4 bytes in 1 blocks are still reachable in loss record 1 of 19
==24573==    at 0x402911D: malloc (in 
/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==24573==    by 0x407C4F3: yyensure_buffer_stack (scanner.c:1644)
==24573==    by 0x407CD32: yylex (scanner.c:800)
==24573==    by 0x407BD92: yyparse (parser.c:1324)
==24573==    by 0x407D471: evaluator_create (matheval.c:81)
==24573==    by 0x810A844: my_func (in /home/blabla/my_binary)

==24573== 48 bytes in 1 blocks are still reachable in loss record 7 of 19
==24573==    at 0x402911D: malloc (in 
/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==24573==    by 0x407C398: yy_create_buffer (scanner.c:1483)
==24573==    by 0x407CD53: yylex (scanner.c:802)
==24573==    by 0x407BD92: yyparse (parser.c:1324)
==24573==    by 0x407D471: evaluator_create (matheval.c:81)
==24573==    by 0x810A844: my_func (in /home/blabla/my_binary)

==24573== 16,386 bytes in 1 blocks are still reachable in loss record 19 of 19
==24573==    at 0x402911D: malloc (in 
/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==24573==    by 0x407C3AC: yy_create_buffer (scanner.c:1492)
==24573==    by 0x407CD53: yylex (scanner.c:802)
==24573==    by 0x407BD92: yyparse (parser.c:1324)
==24573==    by 0x407D471: evaluator_create (matheval.c:81)
==24573==    by 0x810A844: my_func (in /home/blabla/my_binary)

The 16KB bit is specially anoying...


Here are results of the few tests I made:
+ if my_func() is NOT called: no leak
+ if my_func() is called 1 time with good equ: 3 leaks
+ if my_func() is called 1 time with bad equ: same 3 leaks
+ if my_func() is called 2 times with good equ: same 3 leaks
+ if my_func() is called 2 times with bad equ: same 3 leaks
+ if my_func() is called 2 times with good and bad  equ: same 3 leaks
+ if my_func() is called N times with good equ AND/OR bad equ: same 3 leaks

So, I'm not 100% sure about this affirmation, but it looks like the leak 
appears whenever the program is calling evaluator_create() at least once, but 
no mater the number of times.


As I don't know the code of libmatheval, I'm writing to know if the bug is 
known, if someone has seen it, if there is a quick fix....

Thanks for your help

Herve 



reply via email to

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