Discussion:
[Valgrind-users] gcc -pg & valgrind errors
Stijn van Dongen
2003-06-19 19:44:40 UTC
Permalink
Hi,

recently I profiled a program with gprof, so compiled the sources
with -pg (and -g as well by the way, I am assuming those mix without
problems).

At that point valgrind began to emit strange errors; stuff like
[ for a single-statement program importing a thoroughly tested library. ]

[gershwin hobo mcl/shtest > valgrind --num-callers=12 ./tst
==1161== Memcheck, a.k.a. Valgrind, a memory error detector for
x86-linux.
==1161== Copyright (C) 2002, and GNU GPL'd, by Julian Seward.
==1161== Using valgrind-1.9.6, a program instrumentation system for
x86-linux.
==1161== Copyright (C) 2000-2002, and GNU GPL'd, by Julian Seward.
==1161== Estimated CPU clock rate is 449 MHz
==1161== For more details, rerun with: -v
==1161==
==1161== Conditional jump or move depends on uninitialised value(s)
==1161== at 0x4032A049: (within /lib/libc-2.2.5.so)
==1161== by 0x4017E44F: (within
/home/hobo/local/lib/valgrind/valgrind.so)
==1161== by 0x403297CD: moncontrol (in /lib/libc-2.2.5.so)
==1161== by 0x40329EB5: _mcleanup (in /lib/libc-2.2.5.so)
==1161== by 0x40283E52: exit (in /lib/libc-2.2.5.so)
==1161== by 0x40271154: __libc_start_main (in /lib/libc-2.2.5.so)
==1161== by 0x80487D0: (within
/home/hobo/cvs/topaz/micans/mcl/shtest/tst)
==1161==
==1161== Invalid free() / delete / delete[]
==1161== at 0x40167B8B: free (vg_clientfuncs.c:185)
==1161== by 0x40329ED8: _mcleanup (in /lib/libc-2.2.5.so)
==1161== by 0x40283E52: exit (in /lib/libc-2.2.5.so)
==1161== by 0x40271154: __libc_start_main (in /lib/libc-2.2.5.so)
==1161== by 0x80487D0: (within
/home/hobo/cvs/topaz/micans/mcl/shtest/tst)
==1161== Address 0x40375024 is not stack'd, malloc'd or free'd
==1161==
==1161== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
==1161== malloc/free: in use at exit: 233 bytes in 3 blocks.
==1161== malloc/free: 4 allocs, 2 frees, 234 bytes allocated.
==1161== For a detailed leak analysis, rerun with: --leak-check=yes
==1161== For counts of detected errors, rerun with: -v

recompiling with '-g -Wall -pedantic -ansi -O2' and without -pg
make the errors go away.

Is it obvious that I should not use -pg, or should valgrind do
just fine with -pg and must I further investigate this stuff (and
post a minimal example) ? - or does -pg not mix with some of the
other gcc options I am using?

I checked the web docs, and failed in finding an answer there.

regards,
Stijn
Dirk Mueller
2003-06-19 20:38:26 UTC
Permalink
Post by Stijn van Dongen
Is it obvious that I should not use -pg, or should valgrind do
just fine with -pg and must I further investigate this stuff (and
post a minimal example) ? - or does -pg not mix with some of the
other gcc options I am using?
No, you're just hitting bugs in your libc. As you can see nothing references
any function that is in your code, so there is no reason to worry. valgrind
does not difference between application and library code, it simply reports
all errors it finds.

the mcleanup() and similiar handlers are code paths that are only used
during profiling.
--
Dirk
Loading...