Re: Big memory leak in division operator example !
- Posted by Domingo Alvarez Duarte <domingo at dad-it.com> Jun 20, 2007
- 657 views
And here is the converte to C program with "-g" flag and under valgrind: $ valgrind --show-reachable=yes --leak-check=yes ./test-memory-leak2 ==13912== Memcheck, a memory error detector. ==13912== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al. ==13912== Using LibVEX rev 1658, a library for dynamic binary translation. ==13912== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP. ==13912== Using valgrind-3.2.1-Debian, a dynamic binary instrumentation framework. ==13912== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al. ==13912== For more details, rerun with: -v ==13912== ==13912== Invalid write of size 4 ==13912== at 0x80536BE: InitTask (be_task.c:273) ==13912== by 0x8048FF0: (within /home/mingo/downloads/euphoria/euSQLite3/test-memory-leak2) ==13912== Address 0xBE986714 is not stack'd, malloc'd or (recently) free'd ==13912== ==13912== Invalid write of size 4 ==13912== at 0x80536C7: InitTask (be_task.c:279) ==13912== by 0x8048FF0: (within /home/mingo/downloads/euphoria/euSQLite3/test-memory-leak2) ==13912== Address 0xBE9A5714 is not stack'd, malloc'd or (recently) free'd No memory leak till now !!! starting division... Look at the memory leak now !!!! finished... ==13912== ==13912== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 15 from 1) ==13912== malloc/free: in use at exit: 2,980 bytes in 152 blocks. ==13912== malloc/free: 160 allocs, 8 frees, 4,314 bytes allocated. ==13912== For counts of detected errors, rerun with: -v ==13912== searching for pointers to 152 not-freed blocks. ==13912== checked 261,940 bytes. ==13912== ==13912== ==13912== 4 bytes in 1 blocks are still reachable in loss record 1 of 8 ==13912== at 0x4020620: malloc (vg_replace_malloc.c:149) ==13912== by 0x804AD6E: machine (be_machine.c:2523) ==13912== by 0x8048FF0: (within /home/mingo/downloads/euphoria/euSQLite3/test-memory-leak2) ==13912== ==13912== ==13912== 8 bytes in 1 blocks are still reachable in loss record 2 of 8 ==13912== at 0x4020620: malloc (vg_replace_malloc.c:149) ==13912== by 0x804D2FF: shift_args (be_runtime.c:4272) ==13912== by 0x8048FF0: (within /home/mingo/downloads/euphoria/euSQLite3/test-memory-leak2) ==13912== ==13912== ==13912== 8 bytes in 1 blocks are still reachable in loss record 3 of 8 ==13912== at 0x4020620: malloc (vg_replace_malloc.c:149) ==13912== by 0x804E615: eu_startup (be_runtime.c:3624) ==13912== by 0x8048FF0: (within /home/mingo/downloads/euphoria/euSQLite3/test-memory-leak2) ==13912== ==13912== ==13912== 100 bytes in 1 blocks are still reachable in loss record 4 of 8 ==13912== at 0x4020620: malloc (vg_replace_malloc.c:149) ==13912== by 0x8053620: InitTask (be_task.c:242) ==13912== by 0x8048FF0: (within /home/mingo/downloads/euphoria/euSQLite3/test-memory-leak2) ==13912== ==13912== ==13912== 108 bytes in 9 blocks are definitely lost in loss record 5 of 8 ==13912== at 0x4020620: malloc (vg_replace_malloc.c:149) ==13912== by 0x804BC86: NewDouble (be_inline.c:46) ==13912== by 0x8048FF0: (within /home/mingo/downloads/euphoria/euSQLite3/test-memory-leak2) ==13912== ==13912== ==13912== 120 bytes in 10 blocks are still reachable in loss record 6 of 8 ==13912== at 0x4020620: malloc (vg_replace_malloc.c:149) ==13912== by 0x804C71E: tmp_alloc (be_alloc.c:155) ==13912== by 0x8048FF0: (within /home/mingo/downloads/euphoria/euSQLite3/test-memory-leak2) ==13912== ==13912== ==13912== 1,240 bytes in 13 blocks are definitely lost in loss record 7 of 8 ==13912== at 0x4020620: malloc (vg_replace_malloc.c:149) ==13912== by 0x804C62A: NewS1 (be_alloc.c:752) ==13912== by 0x8048FF0: (within /home/mingo/downloads/euphoria/euSQLite3/test-memory-leak2) ==13912== ==13912== ==13912== 1,392 bytes in 116 blocks are still reachable in loss record 8 of 8 ==13912== at 0x4020620: malloc (vg_replace_malloc.c:149) ==13912== by 0x804BC86: NewDouble (be_inline.c:46) ==13912== by 0x8048FF0: (within /home/mingo/downloads/euphoria/euSQLite3/test-memory-leak2) ==13912== ==13912== LEAK SUMMARY: ==13912== definitely lost: 1,348 bytes in 22 blocks. ==13912== possibly lost: 0 bytes in 0 blocks. ==13912== still reachable: 1,632 bytes in 130 blocks. ==13912== suppressed: 0 bytes in 0 blocks.