From: David L <id...@gm...> - 2009-05-14 05:09:37
|
With this code: #include <stdio.h> class MyClass { public: short int foo_ : 6; }; int main(int argc, char *argv[]) { MyClass *gce = new MyClass(); double d=0.0; if (d == 0.0) { printf("d equals zero.\n"); } return 0; } I get this output from valgrind: ==32293== Conditional jump or move depends on uninitialised value(s) ==32293== at 0x804862F: main (main.cpp:11) ==32293== Uninitialised value was created by a heap allocation ==32293== at 0x400674E: operator new(unsigned int) (vg_replace_malloc.c:224) ==32293== by 0x8048610: main (main.cpp:9) If I remove the : 6 from foo_, I don't get the error. Is this a valgrind bug? Thanks, David |
From: Julian S. <js...@ac...> - 2009-05-14 07:25:31
|
On Thursday 14 May 2009, David L wrote: > With this code: > > > #include <stdio.h> > > class MyClass { > public: > short int foo_ : 6; > }; > > int main(int argc, char *argv[]) { > MyClass *gce = new MyClass(); > double d=0.0; > if (d == 0.0) { > printf("d equals zero.\n"); > } > return 0; > } > > I get this output from valgrind: > > > ==32293== Conditional jump or move depends on uninitialised value(s) > ==32293== at 0x804862F: main (main.cpp:11) > ==32293== Uninitialised value was created by a heap allocation > ==32293== at 0x400674E: operator new(unsigned int) > (vg_replace_malloc.c:224) ==32293== by 0x8048610: main (main.cpp:9) > > If I remove the : 6 from foo_, I don't get the error. Is this a valgrind > bug? Hmm, that's ungood. Can you send details of the precise gcc version, the compilation flags, and the what kind of processor you're running on? J |
From: Julian S. <js...@ac...> - 2009-05-14 07:30:24
|
On Thursday 14 May 2009, Julian Seward wrote: > Hmm, that's ungood. Can you send details of the precise gcc version, > the compilation flags, and the what kind of processor you're running on? Oh, and of course, the Valgrind version too. J |
From: David L <id...@gm...> - 2009-05-14 13:29:18
|
On Thu, May 14, 2009 at 12:33 AM, Julian Seward wrote: > >> Hmm, that's ungood. Can you send details of the precise gcc version, >> the compilation flags, and the what kind of processor you're running on? I'm running on a fedora 10 x86 box: valgrind --version valgrind-3.4.1 g++ --version g++ (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7) g++ -g3 -o foo main.cpp valgrind --track-origins=yes foo ==3121== Memcheck, a memory error detector. ==3121== Copyright (C) 2002-2008, and GNU GPL'd, by Julian Seward et al. ==3121== Using LibVEX rev 1884, a library for dynamic binary translation. ==3121== Copyright (C) 2004-2008, and GNU GPL'd, by OpenWorks LLP. ==3121== Using valgrind-3.4.1, a dynamic binary instrumentation framework. ==3121== Copyright (C) 2000-2008, and GNU GPL'd, by Julian Seward et al. ==3121== For more details, rerun with: -v ==3121== ==3121== Conditional jump or move depends on uninitialised value(s) ==3121== at 0x804852F: main (main.cpp:11) ==3121== Uninitialised value was created by a heap allocation ==3121== at 0x400674E: operator new(unsigned int) (vg_replace_malloc.c:224) ==3121== by 0x8048510: main (main.cpp:9) d equals zero. myclass size is 2 ==3121== ==3121== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 16 from 1) ==3121== malloc/free: in use at exit: 2 bytes in 1 blocks. ==3121== malloc/free: 1 allocs, 0 frees, 2 bytes allocated. ==3121== For counts of detected errors, rerun with: -v ==3121== searching for pointers to 1 not-freed blocks. ==3121== checked 89,756 bytes. ==3121== ==3121== LEAK SUMMARY: ==3121== definitely lost: 2 bytes in 1 blocks. ==3121== possibly lost: 0 bytes in 0 blocks. ==3121== still reachable: 0 bytes in 0 blocks. ==3121== suppressed: 0 bytes in 0 blocks. ==3121== Rerun with --leak-check=full to see details of leaked memory. cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 15 model : 3 model name : Intel(R) Pentium(R) 4 CPU 3.00GHz stepping : 4 cpu MHz : 3000.000 cache size : 1024 KB fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 3 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe constant_tsc up pebs bts pni monitor ds_cpl cid xtpr bogomips : 5984.98 clflush size : 64 power management: Thanks, David |
From: Tom H. <to...@co...> - 2009-05-14 14:08:10
|
David L wrote: > ==3121== Conditional jump or move depends on uninitialised value(s) > ==3121== at 0x804852F: main (main.cpp:11) > ==3121== Uninitialised value was created by a heap allocation > ==3121== at 0x400674E: operator new(unsigned int) (vg_replace_malloc.c:224) > ==3121== by 0x8048510: main (main.cpp:9) > d equals zero. > myclass size is 2 What is printing that last line? The code you gave has nothing in it that would print that? Tom -- Tom Hughes (to...@co...) http://www.compton.nu/ |
From: David L <id...@gm...> - 2009-05-14 14:37:29
|
On Thu, May 14, 2009 at 6:36 AM, Tom Hughes <to...@co...> wrote: > David L wrote: > >> ==3121== Conditional jump or move depends on uninitialised value(s) >> ==3121== at 0x804852F: main (main.cpp:11) >> ==3121== Uninitialised value was created by a heap allocation >> ==3121== at 0x400674E: operator new(unsigned int) >> (vg_replace_malloc.c:224) >> ==3121== by 0x8048510: main (main.cpp:9) >> d equals zero. >> myclass size is 2 > > What is printing that last line? The code you gave has nothing in it that > would print that? oops... I was trying to simplify the example that I posted, so I removed that printf from the example code, but I forgot to remove it from the output. Here's the actual code: #include <stdio.h> class MyClass { public: short int foo_ : 6; }; int main(int argc, char *argv[]) { MyClass *gce = new MyClass(); double d=0.0; if (d == 0.0) { printf("d equals zero.\n"); printf("myclass size is %d\n", sizeof(MyClass)); } return 0; } |
From: Tom H. <to...@co...> - 2009-05-14 14:38:55
|
David L wrote: > On Thu, May 14, 2009 at 6:36 AM, Tom Hughes <to...@co...> wrote: >> David L wrote: >> >>> ==3121== Conditional jump or move depends on uninitialised value(s) >>> ==3121== at 0x804852F: main (main.cpp:11) >>> ==3121== Uninitialised value was created by a heap allocation >>> ==3121== at 0x400674E: operator new(unsigned int) >>> (vg_replace_malloc.c:224) >>> ==3121== by 0x8048510: main (main.cpp:9) >>> d equals zero. >>> myclass size is 2 >> What is printing that last line? The code you gave has nothing in it that >> would print that? > > oops... I was trying to simplify the example that I posted, so I removed > that printf from the example code, but I forgot to remove it from the > output. Here's the actual code: Thanks. I don't think it actually makes any difference though. I can reproduce what you're seeing on F10 x86 with the original program. Tom -- Tom Hughes (to...@co...) http://www.compton.nu/ |
From: Julian S. <js...@ac...> - 2009-05-14 15:57:58
|
Tom, > Thanks. I don't think it actually makes any difference though. I can > reproduce what you're seeing on F10 x86 with the original program. Could you pls send the objdump -d of the insn it's complaining about + the few preceding ones, so as to show how the flags get set? J |
From: Tom H. <to...@co...> - 2009-05-14 16:00:59
|
Julian Seward wrote: >> Thanks. I don't think it actually makes any difference though. I can >> reproduce what you're seeing on F10 x86 with the original program. > > Could you pls send the objdump -d of the insn it's complaining about > + the few preceding ones, so as to show how the flags get set? Here's the dump of main - the jp at 0x80484ff is the one that valgrind is complaining about: 080484c4 <main>: 80484c4: 8d 4c 24 04 lea 0x4(%esp),%ecx 80484c8: 83 e4 f0 and $0xfffffff0,%esp 80484cb: ff 71 fc pushl -0x4(%ecx) 80484ce: 55 push %ebp 80484cf: 89 e5 mov %esp,%ebp 80484d1: 51 push %ecx 80484d2: 83 ec 24 sub $0x24,%esp 80484d5: c7 04 24 02 00 00 00 movl $0x2,(%esp) 80484dc: e8 f7 fe ff ff call 80483d8 <_Znwj@plt> 80484e1: 0f b6 10 movzbl (%eax),%edx 80484e4: 83 e2 c0 and $0xffffffc0,%edx 80484e7: 88 10 mov %dl,(%eax) 80484e9: 89 45 ec mov %eax,-0x14(%ebp) 80484ec: d9 ee fldz 80484ee: dd 5d f0 fstpl -0x10(%ebp) 80484f1: dd 45 f0 fldl -0x10(%ebp) 80484f4: d9 ee fldz 80484f6: d9 c9 fxch %st(1) 80484f8: da e9 fucompp 80484fa: df e0 fnstsw %ax 80484fc: 9e sahf 80484fd: 75 0e jne 804850d <main+0x49> 80484ff: 7a 0c jp 804850d <main+0x49> 8048501: c7 04 24 e4 85 04 08 movl $0x80485e4,(%esp) 8048508: e8 db fe ff ff call 80483e8 <puts@plt> 804850d: b8 00 00 00 00 mov $0x0,%eax 8048512: 83 c4 24 add $0x24,%esp 8048515: 59 pop %ecx 8048516: 5d pop %ebp 8048517: 8d 61 fc lea -0x4(%ecx),%esp 804851a: c3 ret Tom -- Tom Hughes (to...@co...) http://www.compton.nu/ |