|
From: Zheng Da <zhe...@gm...> - 2012-05-04 03:45:48
|
Hello, I try to use valgrind to find the memory segmentation bug in my program. When I run it with valgrind, I get a lot of errors such as "Use of uninitialised value" and "Conditional jump or move depends on uninitialised value(s)". And most of errors point to some standard libraries such as glibc and pthread. I can't even see the errors caused by my program. Some of them are shown below. I tried to suppress them with --suppressions, but there are just too many. It's really difficult for me to list all errors caused by the libraries. Is this normal? Is it because my program is written in C++? How do I suppress these errors very effectively? or these errors are actually caused by some bugs of my program? Thanks, Da ==32701== Syscall param set_robust_list(head) points to uninitialised byte(s) ==32701== at 0x41B141: __pthread_initialize_minimal (nptl-init.c:309) ==32701== by 0x47F720: (below main) (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== Address 0x4000bd0 is not stack'd, malloc'd or (recently) free'd ==32701== ==32701== Conditional jump or move depends on uninitialised value(s) ==32701== at 0x4CB436: __register_atfork (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== by 0x4CB558: __libc_pthread_init (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== by 0x41B3A8: __pthread_initialize_minimal (nptl-init.c:445) ==32701== by 0x47F720: (below main) (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== ==32701== Conditional jump or move depends on uninitialised value(s) ==32701== at 0x4CB4E6: __linkin_atfork (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== by 0x49CB66: ptmalloc_init (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== by 0x4A0AD3: malloc_hook_ini (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== by 0x4FD972: _dl_init_paths (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== by 0x4CCC58: _dl_non_dynamic_init (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== by 0x4CD762: __libc_init_first (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== by 0x47F795: (below main) (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== ==32701== Conditional jump or move depends on uninitialised value(s) ==32701== at 0x4A618F: strlen (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== by 0x4FB3D2: fillin_rpath (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== by 0x4FDBCB: _dl_init_paths (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== by 0x4CCC58: _dl_non_dynamic_init (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== by 0x4CD762: __libc_init_first (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== by 0x47F795: (below main) (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== ==32701== Conditional jump or move depends on uninitialised value(s) ==32701== at 0x4FB3D9: fillin_rpath (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== by 0x4FDBCB: _dl_init_paths (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== by 0x4CCC58: _dl_non_dynamic_init (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== by 0x4CD762: __libc_init_first (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== by 0x47F795: (below main) (in /home/zhengda/Dropbox/research/read-test/rand-read) ==32701== ... ==32701== Use of uninitialised value of size 8 ==32701== at 0x405A23: std::vector<page_cache*, std::allocator<page_cache*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<page_cache**, std::vector<page_cache*, std::allocator<page_cache*> > >, page_cache* const&) (vector.tcc:338) ==32701== by 0x404A71: std::vector<page_cache*, std::allocator<page_cache*> >::push_back(page_cache* const&) (stl_vector.h:749) ==32701== by 0x402364: memory_manager::register_cache(page_cache*) (memory_manager.h:82) ==32701== by 0x403991: hash_index_cache::hash_index_cache(memory_manager*) (hash_index_cache.h:235) ==32701== by 0x404441: global_cached_private::create_cache(int, long, memory_manager*) (global_cached_private.h:43) ==32701== by 0x410B11: global_cached_private::global_cached_private(char const**, int, long, int, long, int, int, memory_manager*) (global_cached_private.h:66) ==32701== by 0x40F0E7: main (rand-read.cc:439) ==32701== ==32701== Use of uninitialised value of size 8 ==32701== at 0x405A51: std::vector<page_cache*, std::allocator<page_cache*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<page_cache**, std::vector<page_cache*, std::allocator<page_cache*> > >, page_cache* const&) (vector.tcc:344) ==32701== by 0x404A71: std::vector<page_cache*, std::allocator<page_cache*> >::push_back(page_cache* const&) (stl_vector.h:749) ==32701== by 0x402364: memory_manager::register_cache(page_cache*) (memory_manager.h:82) ==32701== by 0x403991: hash_index_cache::hash_index_cache(memory_manager*) (hash_index_cache.h:235) ==32701== by 0x404441: global_cached_private::create_cache(int, long, memory_manager*) (global_cached_private.h:43) ==32701== by 0x410B11: global_cached_private::global_cached_private(char const**, int, long, int, long, int, int, memory_manager*) (global_cached_private.h:66) ==32701== by 0x40F0E7: main (rand-read.cc:439) ==32701== ==32701== Use of uninitialised value of size 8 ==32701== at 0x405A8D: std::vector<page_cache*, std::allocator<page_cache*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<page_cache**, std::vector<page_cache*, std::allocator<page_cache*> > >, page_cache* const&) (vector.tcc:359) ==32701== by 0x404A71: std::vector<page_cache*, std::allocator<page_cache*> >::push_back(page_cache* const&) (stl_vector.h:749) ==32701== by 0x402364: memory_manager::register_cache(page_cache*) (memory_manager.h:82) ==32701== by 0x403991: hash_index_cache::hash_index_cache(memory_manager*) (hash_index_cache.h:235) ==32701== by 0x404441: global_cached_private::create_cache(int, long, memory_manager*) (global_cached_private.h:43) ==32701== by 0x410B11: global_cached_private::global_cached_private(char const**, int, long, int, long, int, int, memory_manager*) (global_cached_private.h:66) ==32701== by 0x40F0E7: main (rand-read.cc:439) ==32701== |
|
From: Philippe W. <phi...@sk...> - 2012-05-05 15:45:31
|
On Thu, 2012-05-03 at 23:37 -0400, Zheng Da wrote: > Is this normal? Is it because my program is written in C++? How do I > suppress these errors very effectively? or these errors are actually > caused by some bugs of my program? C++ is supported by Valgrind. Valgrind reports some errors in glibc which are normally suppressed using a suppression file. > ==32701== Conditional jump or move depends on uninitialised value(s) > ==32701== at 0x4FB3D9: fillin_rpath > (in /home/zhengda/Dropbox/research/read-test/rand-read) > ==32701== by 0x4FDBCB: _dl_init_paths > (in /home/zhengda/Dropbox/research/read-test/rand-read) > ==32701== by 0x4CCC58: _dl_non_dynamic_init > (in /home/zhengda/Dropbox/research/read-test/rand-read) > ==32701== by 0x4CD762: __libc_init_first > (in /home/zhengda/Dropbox/research/read-test/rand-read) > ==32701== by 0x47F795: (below main) > (in /home/zhengda/Dropbox/research/read-test/rand-read) > ==32701== The above error for example looks to somewhat match a suppression in glibc-2.3.supp It is however not clear what is the cause of all these errors not being suppressed. Note that usually, having more info such as Valgrind version, OS and distribution version, cpu etc might only help to guess what it is :). If you have an old version of Valgrind, you could try to upgrade to a newer one. Philippe |
|
From: Zheng Da <zhe...@gm...> - 2012-05-05 18:25:56
|
hello,
> ==32701== Conditional jump or move depends on uninitialised value(s)
> > ==32701== at 0x4FB3D9: fillin_rpath
> > (in /home/zhengda/Dropbox/research/read-test/rand-read)
> > ==32701== by 0x4FDBCB: _dl_init_paths
> > (in /home/zhengda/Dropbox/research/read-test/rand-read)
> > ==32701== by 0x4CCC58: _dl_non_dynamic_init
> > (in /home/zhengda/Dropbox/research/read-test/rand-read)
> > ==32701== by 0x4CD762: __libc_init_first
> > (in /home/zhengda/Dropbox/research/read-test/rand-read)
> > ==32701== by 0x47F795: (below main)
> > (in /home/zhengda/Dropbox/research/read-test/rand-read)
> > ==32701==
> The above error for example looks to somewhat match a suppression in
> glibc-2.3.supp
>
> It is however not clear what is the cause of all these errors
> not being suppressed.
> Note that usually, having more info such as Valgrind version,
> OS and distribution version, cpu etc might only help to guess
> what it is :).
>
Sorry, I forget.
I use valgrind-3.6.1,
ubuntu 11.04,
Xeon(R) CPU E5405
Linux 2.6.38.8
Other than the errors in the standard library, it also shows many errors in
my own program and I found the error messages are also very misleading.
==21746== Use of uninitialised value of size 8
==21746== at 0x40D168: rand_permute::rand_permute(long, int)
(workload.h:63)
==21746== by 0x410624:
global_rand_permute_workload::global_rand_permute_workload(long, int, long,
long) (workload.h:165)
==21746== by 0x40F3FD: main (rand-read.cc:475)
==21746==
The corresponding code is shown below. I don't understand which variable
isn't initialized?
54 class rand_permute
55 {
56 off_t *offset;
57 long num;
58
59 public:
60 rand_permute(long num, int stride) {
61 offset = (off_t *) valloc(num * sizeof(off_t));
62 for (int i = 0; i < num; i++) {
63 offset[i] = ((off_t) i) * stride;
64 }
65
66 for (int i = num - 1; i >= 1; i--) {
67 int j = random() % i;
68 off_t tmp = offset[j];
69 offset[j] = offset[i];
70 offset[i] = tmp;
71 }
72 }
Thanks,
Da
|
|
From: Geoff A. <gal...@nc...> - 2012-05-05 18:38:44
|
Da,
You dont show the code thats calling rand_permute::rand_permute(long,
int). In particular, the passed in value of stride could be uninitialized.
Geoff
-----Original Message-----
From: Zheng Da [mailto:zhe...@gm...]
Sent: Saturday, May 05, 2012 2:26 PM
To: Philippe Waroquiers
Cc: val...@li...
Subject: Re: [Valgrind-users] valgrind prints out a lot of error messages
pointing to the standard library
hello,
> ==32701== Conditional jump or move depends on uninitialised value(s)
> ==32701== at 0x4FB3D9: fillin_rpath
> (in /home/zhengda/Dropbox/research/read-test/rand-read)
> ==32701== by 0x4FDBCB: _dl_init_paths
> (in /home/zhengda/Dropbox/research/read-test/rand-read)
> ==32701== by 0x4CCC58: _dl_non_dynamic_init
> (in /home/zhengda/Dropbox/research/read-test/rand-read)
> ==32701== by 0x4CD762: __libc_init_first
> (in /home/zhengda/Dropbox/research/read-test/rand-read)
> ==32701== by 0x47F795: (below main)
> (in /home/zhengda/Dropbox/research/read-test/rand-read)
> ==32701==
The above error for example looks to somewhat match a suppression in
glibc-2.3.supp
It is however not clear what is the cause of all these errors
not being suppressed.
Note that usually, having more info such as Valgrind version,
OS and distribution version, cpu etc might only help to guess
what it is :).
Sorry, I forget.
I use valgrind-3.6.1,
ubuntu 11.04,
Xeon(R) CPU E5405
Linux 2.6.38.8
Other than the errors in the standard library, it also shows many errors in
my own program and I found the error messages are also very misleading.
==21746== Use of uninitialised value of size 8
==21746== at 0x40D168: rand_permute::rand_permute(long, int)
(workload.h:63)
==21746== by 0x410624:
global_rand_permute_workload::global_rand_permute_workload(long, int, long,
long) (workload.h:165)
==21746== by 0x40F3FD: main (rand-read.cc:475)
==21746==
The corresponding code is shown below. I don't understand which variable
isn't initialized?
54 class rand_permute
55 {
56 off_t *offset;
57 long num;
58
59 public:
60 rand_permute(long num, int stride) {
61 offset = (off_t *) valloc(num * sizeof(off_t));
62 for (int i = 0; i < num; i++) {
63 offset[i] = ((off_t) i) * stride;
64 }
65
66 for (int i = num - 1; i >= 1; i--) {
67 int j = random() % i;
68 off_t tmp = offset[j];
69 offset[j] = offset[i];
70 offset[i] = tmp;
71 }
72 }
Thanks,
Da
|
|
From: Dan K. <da...@ke...> - 2012-05-05 22:14:31
|
On Sat, May 5, 2012 at 11:38 AM, Geoff Alexander <gal...@nc...> wrote: > You don’t show the code that’s calling rand_permute::rand_permute(long, > int). In particular, the passed in value of stride could be uninitialized. It might be even more helpful to see a small program we can actually compile so we can reproduce the problem here. Make it as small as possible. - Dan |
|
From: Zheng Da <zhe...@gm...> - 2012-05-05 18:45:42
|
157 class global_rand_permute_workload: public workload_gen
158 {
159 long start;
160 long end;
161 static const rand_permute *permute;
162 public:
163 global_rand_permute_workload(long num, int stride, long start, long
end) {
164 if (permute == NULL) {
165 permute = new rand_permute(num, stride);
166 }
167 this->start = start;
168 this->end = end;
169 }
In rand-read.cc,
300 int entry_size = 128;
399 int num_entries = npages * (PAGE_SIZE / entry_size);
473 case RAND_PERMUTE:
474 gen = new global_rand_permute_workload(num_entries,
475 entry_size, start, end);
npages is also initialized. Every variable should have been initialized. I
don't know where the problem is.
Thanks,
Da
476 break;
On Sat, May 5, 2012 at 2:38 PM, Geoff Alexander <gal...@nc...>wrote:
> Da,****
>
> ** ******
>
> You don’t show the code that’s calling rand_permute::rand_permute(long,
> int). In particular, the passed in value of stride could be
> uninitialized.****
>
> ** ******
>
> Geoff****
>
> ** ******
>
> -----Original Message-----
> *From:* Zheng Da [mailto:zhe...@gm...]
> *Sent:* Saturday, May 05, 2012 2:26 PM
> *To:* Philippe Waroquiers
> *Cc:* val...@li...
> *Subject:* Re: [Valgrind-users] valgrind prints out a lot of error
> messages pointing to the standard library
>
> ** ******
>
> hello,****
>
> > ==32701== Conditional jump or move depends on uninitialised value(s)
> > ==32701== at 0x4FB3D9: fillin_rpath
> > (in /home/zhengda/Dropbox/research/read-test/rand-read)
> > ==32701== by 0x4FDBCB: _dl_init_paths
> > (in /home/zhengda/Dropbox/research/read-test/rand-read)
> > ==32701== by 0x4CCC58: _dl_non_dynamic_init
> > (in /home/zhengda/Dropbox/research/read-test/rand-read)
> > ==32701== by 0x4CD762: __libc_init_first
> > (in /home/zhengda/Dropbox/research/read-test/rand-read)
> > ==32701== by 0x47F795: (below main)
> > (in /home/zhengda/Dropbox/research/read-test/rand-read)
> > ==32701==****
>
> The above error for example looks to somewhat match a suppression in
> glibc-2.3.supp
>
> It is however not clear what is the cause of all these errors
> not being suppressed.
> Note that usually, having more info such as Valgrind version,
> OS and distribution version, cpu etc might only help to guess
> what it is :).****
>
> Sorry, I forget.****
>
> I use valgrind-3.6.1, ****
>
> ubuntu 11.04, ****
>
> Xeon(R) CPU E5405****
>
> Linux 2.6.38.8****
>
> ** ******
>
> Other than the errors in the standard library, it also shows many errors
> in my own program and I found the error messages are also very misleading.
> ****
>
> ** ******
>
> ==21746== Use of uninitialised value of size 8****
>
> ==21746== at 0x40D168: rand_permute::rand_permute(long, int)
> (workload.h:63)****
>
> ==21746== by 0x410624:
> global_rand_permute_workload::global_rand_permute_workload(long, int, long,
> long) (workload.h:165)****
>
> ==21746== by 0x40F3FD: main (rand-read.cc:475)****
>
> ==21746== ****
>
> ** ******
>
> The corresponding code is shown below. I don't understand which variable
> isn't initialized?****
>
> ** ******
>
> 54 class rand_permute****
>
> 55 {****
>
> 56 off_t *offset;****
>
> 57 long num;****
>
> 58 ****
>
> 59 public:****
>
> 60 rand_permute(long num, int stride) {****
>
> 61 offset = (off_t *) valloc(num * sizeof(off_t));****
>
> 62 for (int i = 0; i < num; i++) {****
>
> 63 offset[i] = ((off_t) i) * stride;****
>
> 64 }****
>
> 65 ****
>
> 66 for (int i = num - 1; i >= 1; i--) {****
>
> 67 int j = random() % i;****
>
> 68 off_t tmp = offset[j];****
>
> 69 offset[j] = offset[i];****
>
> 70 offset[i] = tmp;****
>
> 71 }****
>
> 72 }****
>
> ** ******
>
> Thanks,****
>
> Da****
>
|
|
From: Philippe W. <phi...@sk...> - 2012-05-05 22:10:16
|
On Sat, 2012-05-05 at 14:45 -0400, Zheng Da wrote:
>
> The corresponding code is shown below. I don't understand
> which variable isn't initialized?
If you upgrade to Valgrind 3.7.0, you can use gdb to debug
your program under Valgrind.
With this, you have GDB monitor commands to ask if an address
is initialised (or not).
See user manual, sections
3.2. Debugging your program using Valgrind gdbserver and GDB
and 4.6. Memcheck Monitor Commands
This might make it easier to understand where the problem
is coming from.
Philippe
|