Please reply to the group, not just me, and please don't top-post. My
reply is at the bottom.
On 6/12/2013 1:35 AM, Sanjay Kumar (sanjaku5) wrote:
Hi David,
Below is code which I added to create the leak in my application :
/*******************/
char *mleak = NULL;
static int mcnt = 0;
mleak = (char *)malloc(10000);
if(NULL == mleak)
printf("\nmleak is NULL\n");
strcpy(mleak, "aaaaaaaaaaaaaaaaaaaaaaa");
printf("\nmleak called:%d mleak:%s \n", mcnt++, mleak);
/*******************/
Below is summary of report:
==11597== Memcheck, a memory error detector
==11597== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==11597== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright
info
==11597== Command: ./flare -f syfer.conf
==11597==
--11597-- Valgrind options:
--11597-- -v
--11597-- --tool=memcheck
--11597-- --leak-check=full
--11597-- --leak-resolution=high
--11597-- Contents of /proc/version:
--11597-- Linux version 2.6.38-staros-v3-40087-deb-32 (root@releng7)
(gcc version 3.3.5 (Debian 1:3.3.5-13)) #1 SMP PREEMPT Sat Oct 1
02:50:26 EDT 2011
--11597-- Arch and hwcaps: X86, x86-sse1-sse2
--11597-- Page sizes: currently 4096, max supported 4096
--11597-- Valgrind library directory: /usr/local/lib/valgrind
--11597-- Reading syms from /usr/local/flare/flare
--11597-- object doesn't have a dynamic symbol table
--11597-- warning: DiCfSI 0x0 .. 0x0 outside mapped rw segments (NONE)
--11597-- warning: DiCfSI 0x1 .. 0x2 outside mapped rw segments (NONE)
--11597-- warning: DiCfSI 0x3 .. 0x8 outside mapped rw segments (NONE)
--11597-- warning: DiCfSI 0x9 .. 0x437 outside mapped rw segments (NONE)
--11597-- warning: DiCfSI 0x0 .. 0x0 outside mapped rw segments (NONE)
--11597-- warning: DiCfSI 0x1 .. 0x2 outside mapped rw segments (NONE)
--11597-- warning: DiCfSI 0x3 .. 0x8 outside mapped rw segments (NONE)
--11597-- warning: DiCfSI 0x9 .. 0x3a6 outside mapped rw segments (NONE)
--11597-- warning: DiCfSI 0x0 .. 0x0 outside mapped rw segments (NONE)
--11597-- warning: DiCfSI 0x1 .. 0x2 outside mapped rw segments (NONE)
--11597-- Reading syms from /usr/local/lib/valgrind/memcheck-x86-linux
--11597-- object doesn't have a dynamic symbol table
--11597-- Scheduler: using generic scheduler lock implementation.
--11597-- Reading suppressions file: /usr/local/lib/valgrind/default.supp
==11597== embedded gdbserver: reading from
/tmp/vgdb-pipe-from-vgdb-to-11597-by-root-on-???
==11597== embedded gdbserver: writing to
/tmp/vgdb-pipe-to-vgdb-from-11597-by-root-on-???
==11597== embedded gdbserver: shared mem
/tmp/vgdb-pipe-shared-mem-vgdb-11597-by-root-on-???
==11597==
==11597==
==11597== TO CONTROL THIS PROCESS USING vgdb (which you probably
==11597== don't want to do, unless you know exactly what you're doing,
==11597== or are doing some strange experiment):
==11597== /usr/local/lib/valgrind/../../bin/vgdb --pid=11597 ...command...
==11597==
==11597== TO DEBUG THIS PROCESS USING GDB: start GDB like this
==11597== /path/to/gdb ./flare
==11597== and then give GDB the following command
==11597== target remote | /usr/local/lib/valgrind/../../bin/vgdb
--pid=11597
==11597== --pid is optional if only one valgrind process is running
==11597==
==11597== Conditional jump or move depends on uninitialised value(s)
==11597== at 0x8A838B5: __register_atfork (in /usr/local/flare/flare)
==11597== by 0x8A68074: ptmalloc_init (in /usr/local/flare/flare)
==11597== by 0x8A6C265: malloc_hook_ini (in /usr/local/flare/flare)
==11597== by 0x8A6BDCE: malloc (in /usr/local/flare/flare)
==11597== by 0x8AA893B: _dl_init_paths (in /usr/local/flare/flare)
==11597== by 0x8A8BDBB: _dl_non_dynamic_init (in
/usr/local/flare/flare)
==11597== by 0x8A8CA75: __libc_init_first (in /usr/local/flare/flare)
==11597== by 0x8A3E460: (below main) (in /usr/local/flare/flare)
==11597==
==11597== Conditional jump or move depends on uninitialised value(s)
==11597== at 0x8A83926: __register_atfork (in /usr/local/flare/flare)
==11597== by 0x8A68074: ptmalloc_init (in /usr/local/flare/flare)
==11597== by 0x8A6C265: malloc_hook_ini (in /usr/local/flare/flare)
==11597== by 0x8A6BDCE: malloc (in /usr/local/flare/flare)
==11597== by 0x8AA893B: _dl_init_paths (in /usr/local/flare/flare)
==11597== by 0x8A8BDBB: _dl_non_dynamic_init (in
/usr/local/flare/flare)
==11597== by 0x8A8CA75: __libc_init_first (in /usr/local/flare/flare)
==11597== by 0x8A3E460: (below main) (in /usr/local/flare/flare)
......
...........
.............
==11597==
==11597== 481512 errors in context 998 of 1000:
==11597== Invalid read of size 4
==11597== at 0x8A6FBCF: memcpy (in /usr/local/flare/flare)
==11597== by 0x80D9F80:
configuration::cfgparams::read_pattern(std::string, std::string,
fsm_t*) (stl_iterator.h:704)
==11597== by 0x8086EE2:
configuration::cfg::read_pattern(configuration::configfile*,
std::string, bool, unsigned short) (cfgdata.cpp:1684)
==11597== by 0x8088215: configuration::cfg::read_pattern_file()
(cfgdata.cpp:780)
==11597== by 0x809935B: configuration::cfg::read_config_file()
(cfgdata.cpp:623)
==11597== by 0x811576D: main (main.cpp:3930)
==11597== Address 0xbef88714 is on thread 1's stack
==11597==
==11597==
==11597== 481512 errors in context 999 of 1000:
==11597== Invalid read of size 4
==11597== at 0x8A6FBCF: memcpy (in /usr/local/flare/flare)
==11597== by 0x80D9CD4:
configuration::cfgparams::read_pattern(std::string, std::string,
fsm_t*) (stl_iterator.h:704)
==11597== by 0x8086EE2:
configuration::cfg::read_pattern(configuration::configfile*,
std::string, bool, unsigned short) (cfgdata.cpp:1684)
==11597== by 0x8088215: configuration::cfg::read_pattern_file()
(cfgdata.cpp:780)
==11597== by 0x809935B: configuration::cfg::read_config_file()
(cfgdata.cpp:623)
==11597== by 0x811576D: main (main.cpp:3930)
==11597== Address 0xbefc3388 is on thread 1's stack
==11597==
==11597==
==11597== 662079 errors in context 1000 of 1000:
==11597== Invalid read of size 4
==11597== at 0x8A6FBCF: memcpy (in /usr/local/flare/flare)
==11597== by 0x80DC54B: void
std::__uninitialized_fill_n_aux<__gnu_cxx::__normal_iterator<flare_stack*,
std::vector<flare_stack, std::allocator<flare_stack> > >, unsigned
int, flare_stack>(__gnu_cxx::__normal_iterator<flare_stack*,
std::vector<flare_stack, std::allocator<flare_stack> > >, unsigned
int, flare_stack const&, __false_type) (stl_construct.h:81)
==11597== by 0x80DEAE5: std::vector<flare_stack,
std::allocator<flare_stack>
>::_M_fill_insert(__gnu_cxx::__normal_iterator<flare_stack*,
std::vector<flare_stack, std::allocator<flare_stack> > >, unsigned
int, flare_stack const&) (vector.tcc:365)
==11597== by 0x80DB8C4:
configuration::cfgparams::read_pattern(std::string, std::string,
fsm_t*) (stl_vector.h:658)
==11597== by 0x8086EE2:
configuration::cfg::read_pattern(configuration::configfile*,
std::string, bool, unsigned short) (cfgdata.cpp:1684)
==11597== by 0x8088215: configuration::cfg::read_pattern_file()
(cfgdata.cpp:780)
==11597== by 0x809935B: configuration::cfg::read_config_file()
(cfgdata.cpp:623)
==11597== by 0x811576D: main (main.cpp:3930)
==11597== Address 0xbedb2374 is on thread 1's stack
==11597==
==11597== ERROR SUMMARY: 3704242 errors from 1000 contexts
(suppressed: 0 from 0)
*When the same code I run as test program valgrind able to detect the
leak.*
*But NOT when it is part of my application.***
Thanks,
Sanjay
I'll leave the details of why leaks would not be reported to the
Valgrind development team. But it seems to me that you have plenty to
work on already: 3,704,242 errors of various kinds. If these are
cleaned up, what happens then?
I suppose it is possible that Valgrind doesn't notice leaks among all of
the other reports, but IMO that is a much smaller problem than reading
out-of-bounds memory and executing instructions based on uninitialized
data. My goal is always zero errors from Valgrind, even if the program
seems to work fine without any changes. Fix the errors that Valgrind
reports now and let us know if there are still problems with leak reporting.
--
David Chapman dcchap...@acm.org
Chapman Consulting -- San Jose, CA
Software Development Done Right.
www.chapman-consulting-sj.com
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users