|
From: sankoor s. <sam...@ya...> - 2015-03-03 04:59:23
|
Hi, Am very new valgrind, pl help me out: I have daemon running on linux machine, in which i have injected 1MB memory leak & trying to find memory leak in a daemon using valgrind. But am not able to get the proper memory leak ouptut , Pl find the below the valgrind o/p: /usr/bin/valgrind --tool=memcheck --num-callers=8 --leak-check=full --leak-resolution=high --error-limit=no --show-reachable=yes --track-origins=yes startsrc -s FSRM ==2476== Memcheck, a memory error detector ==2476== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al. ==2476== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info ==2476== Command: startsrc -s FSRM ==2476== ==2476== Conditional jump or move depends on uninitialised value(s) ==2476== at 0x4018566: index (in /usr/lib64/ld-2.17.so) ==2476== by 0x40079D3: expand_dynamic_string_token (in /usr/lib64/ld-2.17.so) ==2476== by 0x40084F5: _dl_map_object (in /usr/lib64/ld-2.17.so) ==2476== by 0x400160D: map_doit (in /usr/lib64/ld-2.17.so) ==2476== by 0x400F313: _dl_catch_error (in /usr/lib64/ld-2.17.so) ==2476== by 0x4000E8D: do_preload (in /usr/lib64/ld-2.17.so) ==2476== by 0x4004296: dl_main (in /usr/lib64/ld-2.17.so) ==2476== by 0x4016244: _dl_sysdep_start (in /usr/lib64/ld-2.17.so) ==2476== Uninitialised value was created by a stack allocation ==2476== at 0x4004224: dl_main (in /usr/lib64/ld-2.17.so) ==2476== ==2476== Conditional jump or move depends on uninitialised value(s) ==2476== at 0x401856B: index (in /usr/lib64/ld-2.17.so) ==2476== by 0x40079D3: expand_dynamic_string_token (in /usr/lib64/ld-2.17.so) ==2476== by 0x40084F5: _dl_map_object (in /usr/lib64/ld-2.17.so) ==2476== by 0x400160D: map_doit (in /usr/lib64/ld-2.17.so) ==2476== by 0x400F313: _dl_catch_error (in /usr/lib64/ld-2.17.so) ==2476== by 0x4000E8D: do_preload (in /usr/lib64/ld-2.17.so) ==2476== by 0x4004296: dl_main (in /usr/lib64/ld-2.17.so) ==2476== by 0x4016244: _dl_sysdep_start (in /usr/lib64/ld-2.17.so) ==2476== Uninitialised value was created by a stack allocation ==2476== at 0x4004224: dl_main (in /usr/lib64/ld-2.17.so) ==2476== ==2476== Conditional jump or move depends on uninitialised value(s) ==2476== at 0x4018577: index (in /usr/lib64/ld-2.17.so) ==2476== by 0x40079D3: expand_dynamic_string_token (in /usr/lib64/ld-2.17.so) ==2476== by 0x40084F5: _dl_map_object (in /usr/lib64/ld-2.17.so) ==2476== by 0x400160D: map_doit (in /usr/lib64/ld-2.17.so) ==2476== by 0x400F313: _dl_catch_error (in /usr/lib64/ld-2.17.so) ==2476== by 0x4000E8D: do_preload (in /usr/lib64/ld-2.17.so) ==2476== by 0x4004296: dl_main (in /usr/lib64/ld-2.17.so) ==2476== by 0x4016244: _dl_sysdep_start (in /usr/lib64/ld-2.17.so) ==2476== Uninitialised value was created by a stack allocation ==2476== at 0x4004224: dl_main (in /usr/lib64/ld-2.17.so) ==2476== 0513-059 The FSRM Subsystem has been started. Subsystem PID is 2477. ==2476== ==2476== HEAP SUMMARY: ==2476== in use at exit: 3,620 bytes in 3 blocks ==2476== total heap usage: 40 allocs, 37 frees, 7,841 bytes allocated ==2476== ==2476== 528 bytes in 1 blocks are still reachable in loss record 1 of 3 ==2476== at 0x4C289EE: malloc (vg_replace_malloc.c:270) ==2476== by 0x505015E: breakcrit (odmfind.c:434) ==2476== by 0x5050BDB: raw_find_obj (odmfind.c:659) ==2476== by 0x5058BBA: odm_get_obj (odmi.c:3019) ==2476== by 0x4E39AF1: readrec (srcodm.c:110) ==2476== by 0x4E3780A: cmdargs (cmdargs.c:364) ==2476== by 0x400BEC: main (start.c:126) ==2476== ==2476== 1,288 bytes in 1 blocks are still reachable in loss record 2 of 3 ==2476== at 0x4C289EE: malloc (vg_replace_malloc.c:270) ==2476== by 0x505B270: odm_mount_class (odmi.c:3867) ==2476== by 0x50589E5: odm_get_obj (odmi.c:2981) ==2476== by 0x4E39AF1: readrec (srcodm.c:110) ==2476== by 0x4E3780A: cmdargs (cmdargs.c:364) ==2476== by 0x400BEC: main (start.c:126) ==2476== ==2476== 1,804 bytes in 1 blocks are definitely lost in loss record 3 of 3 ==2476== at 0x4C289EE: malloc (vg_replace_malloc.c:270) ==2476== by 0x505B27F: odm_mount_class (odmi.c:3868) ==2476== by 0x50589E5: odm_get_obj (odmi.c:2981) ==2476== by 0x4E39AF1: readrec (srcodm.c:110) ==2476== by 0x4E3780A: cmdargs (cmdargs.c:364) ==2476== by 0x400BEC: main (start.c:126) ==2476== ==2476== LEAK SUMMARY: ==2476== definitely lost: 1,804 bytes in 1 blocks ==2476== indirectly lost: 0 bytes in 0 blocks ==2476== possibly lost: 0 bytes in 0 blocks ==2476== still reachable: 1,816 bytes in 2 blocks ==2476== suppressed: 0 bytes in 0 blocks ==2476== ==2476== For counts of detected and suppressed errors, rerun with: -v ==2476== ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 0 from 0) Daemon name : FSRM Memory leak introduced as :char* skg = (char*)malloc (10000*sizeof(char)); ThanksSampath S. |
|
From: John R. <jr...@bi...> - 2015-03-03 06:05:34
|
> Memory leak introduced as :char* skg = (char*)malloc (10000*sizeof(char)); Write the smallest possible program that contains the above statement but also causes memcheck to report a leak. You must run the program under memcheck and get an actual leak report. Thinking "it's so easy, that definitely leaks!" is NOT sufficient. Compare and contrast your daemon with that smallest possible program that leaks. |
|
From: Philippe W. <phi...@sk...> - 2015-03-03 21:17:43
|
On Tue, 2015-03-03 at 04:59 +0000, sankoor sampath wrote: > Hi, > > Am very new valgrind, pl help me out: > I have daemon running on linux machine, in which i have injected 1MB > memory leak & trying to find memory leak in a daemon using valgrind. > But am not able to get the proper memory leak ouptut , Pl find the > below the valgrind o/p: ... > ==2476== > 0513-059 The FSRM Subsystem has been started. Subsystem PID is 2477. > ==2476== Isn't the above indicating that the daemon is started as a child process of 2476 ? Then you should use --trace-children=yes to ensure valgrind also instruments the daemon process. Philippe |