You are not logged in.

#1 2007-08-16 00:45:47

Jessehk
Member
From: Toronto, Ontario, Canada
Registered: 2007-01-16
Posts: 152

Valgrind reports errors on "hello, world"

Hi all.

I use valgrind when I'm playing around with C or C++ to make sure I haven't made any mistakes with memory.
On a simple "Hello, World" program in C, valgrind reports 13 errors. This isn't such a big problem, but it distracts from my own errors.
It doesn't occur on other distributions I've used so I'm thinking it's fixable. Any info would be great. smile

#include <stdio.h>

int main( void ) {
    puts( "Hello, world!" );
    
    return 0;
}
$ gcc hello.c -o hello
$ valgrind ./hello
==18712== Memcheck, a memory error detector.
==18712== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==18712== Using LibVEX rev 1732, a library for dynamic binary translation.
==18712== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==18712== Using valgrind-3.2.3, a dynamic binary instrumentation framework.
==18712== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==18712== For more details, rerun with: -v
==18712== 
==18712== Conditional jump or move depends on uninitialised value(s)
==18712==    at 0x400A7B2: _dl_relocate_object (do-rel.h:65)
==18712==    by 0x4003743: dl_main (rtld.c:2207)
==18712==    by 0x401385C: _dl_sysdep_start (dl-sysdep.c:239)
==18712==    by 0x40011C0: _dl_start (rtld.c:323)
==18712==    by 0x4000816: (within /lib/ld-2.6.1.so)
==18712== 
==18712== Conditional jump or move depends on uninitialised value(s)
==18712==    at 0x400A7BA: _dl_relocate_object (do-rel.h:68)
==18712==    by 0x4003743: dl_main (rtld.c:2207)
==18712==    by 0x401385C: _dl_sysdep_start (dl-sysdep.c:239)
==18712==    by 0x40011C0: _dl_start (rtld.c:323)
==18712==    by 0x4000816: (within /lib/ld-2.6.1.so)
==18712== 
==18712== Conditional jump or move depends on uninitialised value(s)
==18712==    at 0x400A8D5: _dl_relocate_object (do-rel.h:104)
==18712==    by 0x4003743: dl_main (rtld.c:2207)
==18712==    by 0x401385C: _dl_sysdep_start (dl-sysdep.c:239)
==18712==    by 0x40011C0: _dl_start (rtld.c:323)
==18712==    by 0x4000816: (within /lib/ld-2.6.1.so)
==18712== 
==18712== Conditional jump or move depends on uninitialised value(s)
==18712==    at 0x400A910: _dl_relocate_object (do-rel.h:117)
==18712==    by 0x4003743: dl_main (rtld.c:2207)
==18712==    by 0x401385C: _dl_sysdep_start (dl-sysdep.c:239)
==18712==    by 0x40011C0: _dl_start (rtld.c:323)
==18712==    by 0x4000816: (within /lib/ld-2.6.1.so)
==18712== 
==18712== Conditional jump or move depends on uninitialised value(s)
==18712==    at 0x400B3AB: _dl_relocate_object (do-rel.h:127)
==18712==    by 0x4003743: dl_main (rtld.c:2207)
==18712==    by 0x401385C: _dl_sysdep_start (dl-sysdep.c:239)
==18712==    by 0x40011C0: _dl_start (rtld.c:323)
==18712==    by 0x4000816: (within /lib/ld-2.6.1.so)
==18712== 
==18712== Conditional jump or move depends on uninitialised value(s)
==18712==    at 0x400A7B2: _dl_relocate_object (do-rel.h:65)
==18712==    by 0x40039C9: dl_main (rtld.c:2277)
==18712==    by 0x401385C: _dl_sysdep_start (dl-sysdep.c:239)
==18712==    by 0x40011C0: _dl_start (rtld.c:323)
==18712==    by 0x4000816: (within /lib/ld-2.6.1.so)
==18712== 
==18712== Conditional jump or move depends on uninitialised value(s)
==18712==    at 0x400A7BA: _dl_relocate_object (do-rel.h:68)
==18712==    by 0x40039C9: dl_main (rtld.c:2277)
==18712==    by 0x401385C: _dl_sysdep_start (dl-sysdep.c:239)
==18712==    by 0x40011C0: _dl_start (rtld.c:323)
==18712==    by 0x4000816: (within /lib/ld-2.6.1.so)
==18712== 
==18712== Conditional jump or move depends on uninitialised value(s)
==18712==    at 0x400A910: _dl_relocate_object (do-rel.h:117)
==18712==    by 0x40039C9: dl_main (rtld.c:2277)
==18712==    by 0x401385C: _dl_sysdep_start (dl-sysdep.c:239)
==18712==    by 0x40011C0: _dl_start (rtld.c:323)
==18712==    by 0x4000816: (within /lib/ld-2.6.1.so)
Hello, world!
==18712== 
==18712== ERROR SUMMARY: 13 errors from 8 contexts (suppressed: 0 from 0)
==18712== malloc/free: in use at exit: 0 bytes in 0 blocks.
==18712== malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
==18712== For counts of detected errors, rerun with: -v
==18712== All heap blocks were freed -- no leaks are possible.

Last edited by Jessehk (2007-08-16 00:46:09)

Offline

#2 2007-08-16 01:21:16

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: Valgrind reports errors on "hello, world"

Apparently those errors are common with a stripped ld.so
Other distros are probably either: a) not stripped, b) using tuned supressions.

http://valgrind.org/docs/manual/faq.html#faq.writesupp
I recommend configuring suppressions to block those specific messages, as they are all ld.so in origin.

edit:
http://svn.python.org/projects/python/t … ython.supp
search for "ld problems" and you will see some examples.


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#3 2007-08-16 01:46:04

Jessehk
Member
From: Toronto, Ontario, Canada
Registered: 2007-01-16
Posts: 152

Re: Valgrind reports errors on "hello, world"

Thanks, cactus.

I fixed the errors by appending this:

{
   ld error suppression
   Memcheck:Cond
   fun:_dl_relocate_object
   fun:dl_main
   fun:_dl_sysdep_start
   fun:_dl_start
   obj:/lib/ld-2.6.1.so
}

to the end of /usr/lib/valgrind/default.supp

Offline

#4 2007-08-16 05:48:00

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,425
Website

Re: Valgrind reports errors on "hello, world"

Should these lines be added by default in the valgrind package.  I think everyone will need them.  Is there any downside?

Offline

#5 2007-08-16 08:31:07

TheGrudge
Member
Registered: 2006-06-15
Posts: 206
Website

Re: Valgrind reports errors on "hello, world"

I think with the next update of valgrind your modifications will be lost. I created a file in my homefolder and an alias for valgrind so it automatically uses this suppressions file.

alias valgrind="valgrind --suppressions=~/.myvalgrind.supp"

digiKam developer - www.digikam.org

Offline

#6 2007-08-16 12:53:02

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,425
Website

Re: Valgrind reports errors on "hello, world"

TheGrudge wrote:

I think with the next update of valgrind your modifications will be lost.

That file can easily be backed up or a .pacnew file created along side it at upgrade - much like other config files.  I think if this a step every user needs to perform, then it should be included by default.

Offline

#7 2007-08-16 20:06:36

codemac
Member
From: Cliche Tech Place
Registered: 2005-05-13
Posts: 794
Website

Re: Valgrind reports errors on "hello, world"

Allan wrote:

Should these lines be added by default in the valgrind package.  I think everyone will need them.  Is there any downside?

What if you are running arch without a stripped ld?  Arch is all about sane defaults, and I think it's insane to suppress warnings out of the box from a debugger.  I know that arch is shipping with something that puts out errors on a Hello World, but if you are using Valgrind, you should probably know that arch ships stripped binaries ( Which I still disagree with ).

Offline

#8 2007-08-16 21:31:05

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,425
Website

Re: Valgrind reports errors on "hello, world"

codemac wrote:

What if you are running arch without a stripped ld?  Arch is all about sane defaults, and I think it's insane to suppress warnings out of the box from a debugger.  I know that arch is shipping with something that puts out errors on a Hello World, but if you are using Valgrind, you should probably know that arch ships stripped binaries ( Which I still disagree with ).

Fair enough.  How about a post install message saying "By default Arch ships with a stripped ld, so blah..."?

Offline

#9 2007-08-16 22:34:51

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Valgrind reports errors on "hello, world"

codemac wrote:
Allan wrote:

Should these lines be added by default in the valgrind package.  I think everyone will need them.  Is there any downside?

What if you are running arch without a stripped ld?  Arch is all about sane defaults, and I think it's insane to suppress warnings out of the box from a debugger.  I know that arch is shipping with something that puts out errors on a Hello World, but if you are using Valgrind, you should probably know that arch ships stripped binaries ( Which I still disagree with ).

I think codemac is right here, but not for the same reasons.
Adding these suppressions by default is just more hiding. To me, it's the same as replacing some binary with a script like this:

#!/bin/sh
somebinary > /dev/null 2>&1

There's nothing wrong with that but information is lost and hidden. Let's let the user decide what information the user wants to throw away, instead of enforcing it at the distro level.

I'm all for sticking some default suppressions in /usr/share or something like that, but having it "on" by default doesn't sit right.

Offline

Board footer

Powered by FluxBB