hlsyounes / mdpsim

PPDDL plan evalutation simulator
Apache License 2.0
14 stars 5 forks source link

memory leak in terms.cc at lines 131 and 133 #8

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. run mdpsim on the blocksworld domain with problem p01.pddl from IPC-5
2. run a client with valgrind:

valgrind --tool=memcheck --leak-check=full /path/to/client --port=2323
--host=localhost /path/to/blocksworld-domain.pddl /path/to/p01-problem.pddl

3. notice the memory leak in valgrind's output due to the non deletion of
the variable 'objects' at lines 131 and 133 of file 'terms.cc':

==7905== 
==7905== ERROR SUMMARY: 2403 errors from 1 contexts (suppressed: 19 from 1)
==7905== malloc/free: in use at exit: 16,986 bytes in 44 blocks.
==7905== malloc/free: 2,283,783 allocs, 2,283,739 frees, 48,827,677 bytes
allocated.
==7905== For counts of detected errors, rerun with: -v
==7905== searching for pointers to 44 not-freed blocks.
==7905== checked 119,792 bytes.
==7905== 
==7905== 
==7905== 168 bytes in 14 blocks are definitely lost in loss record 1 of 4
==7905==    at 0x4023294: operator new(unsigned) (vg_replace_malloc.c:224)
==7905==    by 0x405DA76: TermTable::compatible_objects(Type const&) const
(terms.cc:133)
==7905==    by 0x405D96B: TermTable::compatible_objects(Type const&) const
(terms.cc:131)
==7905==    by 0x406EC92: ActionSchema::instantiations(ActionSet&,
TermTable const&, AtomSet const&, ValueMap const&) const (actions.cc:79)
==7905==    by 0x4073133: Problem::instantiate() (problems.cc:178)
==7905==    by 0x407E4B1: yyparse() (parser.yy:551)
==7905==    by 0x80D958B: main (main_caylustest.cc:234)
==7905== 
==7905== 
==7905== 392 (168 direct, 224 indirect) bytes in 14 blocks are definitely
lost in loss record 2 of 4
==7905==    at 0x4023294: operator new(unsigned) (vg_replace_malloc.c:224)
==7905==    by 0x405D97A: TermTable::compatible_objects(Type const&) const
(terms.cc:131)
==7905==    by 0x406EC92: ActionSchema::instantiations(ActionSet&,
TermTable const&, AtomSet const&, ValueMap const&) const (actions.cc:79)
==7905==    by 0x4073133: Problem::instantiate() (problems.cc:178)
==7905==    by 0x407E4B1: yyparse() (parser.yy:551)
==7905==    by 0x80D958B: main (main_caylustest.cc:234)
==7905== 
==7905== 
==7905== 224 bytes in 14 blocks are indirectly lost in loss record 3 of 4
==7905==    at 0x4023294: operator new(unsigned) (vg_replace_malloc.c:224)
==7905==    by 0x405E455: std::vector<Object, std::allocator<Object>
>::_M_insert_aux(__gnu_cxx::__normal_iterator<Object*, std::vector<Object,
std::allocator<Object> > >, Object const&) (new_allocator.h:91)
==7905==    by 0x405DA68: TermTable::compatible_objects(Type const&) const
(stl_vector.h:605)
==7905==    by 0x406EC92: ActionSchema::instantiations(ActionSet&,
TermTable const&, AtomSet const&, ValueMap const&) const (actions.cc:79)
==7905==    by 0x4073133: Problem::instantiate() (problems.cc:178)
==7905==    by 0x407E4B1: yyparse() (parser.yy:551)
==7905==    by 0x80D958B: main (main_caylustest.cc:234)
==7905== 
==7905== 
==7905== 16,426 bytes in 2 blocks are still reachable in loss record 4 of 4
==7905==    at 0x4022AB8: malloc (vg_replace_malloc.c:207)
==7905==    by 0x40818A9: yy_flex_alloc(unsigned) (tokenizer.cc:2137)
==7905==    by 0x4081A96: yy_create_buffer(_IO_FILE*, int) (tokenizer.cc:1808)
==7905==    by 0x4081E70: yylex() (tokenizer.cc:890)
==7905==    by 0x407C586: yyparse() (parser.cc:2250)
==7905==    by 0x80D958B: main (main_caylustest.cc:234)
==7905== 
==7905== LEAK SUMMARY:
==7905==    definitely lost: 336 bytes in 28 blocks.
==7905==    indirectly lost: 224 bytes in 14 blocks.
==7905==      possibly lost: 0 bytes in 0 blocks.
==7905==    still reachable: 16,426 bytes in 2 blocks.
==7905==         suppressed: 0 bytes in 0 blocks.

What is the expected output? What do you see instead?

valgrind should report no memory leak.
Perhaps ObjectList class should derive from ObjectRC class, so that it
could be automatically deleted?

What version of the product are you using? On what operating system?

mdpsim-2.2.2 on linux ubuntu 8.04

Please provide any additional information below.

Original issue reported on code.google.com by florent....@gmail.com on 5 Jun 2008 at 9:18

hlsyounes commented 4 years ago

Reproducible with tcmalloc heap checker.

$ PPROF_PATH=/usr/local/bin/pprof HEAPCHECK=normal ./mdpclient --host=localhost --port=2323 ~/tmp/problems/final/probabilistic/blocksworld/domain.pddl ~/tmp/problems/final/probabilistic/blocksworld/p01.pddl
...
Leak of 320 bytes in 10 objects allocated from:
    @ 55f51f387e6c std::vector::_M_realloc_insert
    @ 55f51f3877cc TermTable::compatible_objects
    @ 55f51f393403 ActionSchema::instantiations
    @ 55f51f396a55 Problem::instantiate
    @ 55f51f39eb23 yyparse
    @ 55f51f37e33b main
    @ 7ffb349ce52b __libc_start_main
    @ 55f51f37f20a _start
Leak of 288 bytes in 12 objects allocated from:
    @ 55f51f3877d8 TermTable::compatible_objects
    @ 55f51f38768f TermTable::compatible_objects
    @ 55f51f393403 ActionSchema::instantiations
    @ 55f51f396a55 Problem::instantiate
    @ 55f51f39eb23 yyparse
    @ 55f51f37e33b main
    @ 7ffb349ce52b __libc_start_main
    @ 55f51f37f20a _start
Leak of 240 bytes in 10 objects allocated from:
    @ 55f51f38769c TermTable::compatible_objects
    @ 55f51f393403 ActionSchema::instantiations
    @ 55f51f396a55 Problem::instantiate
    @ 55f51f39eb23 yyparse
    @ 55f51f37e33b main
    @ 7ffb349ce52b __libc_start_main
    @ 55f51f37f20a _start