|
From: Jesper O. <jes...@gm...> - 2005-06-05 06:00:15
|
Hi,
I just installed valgrind 2.4.0 under linux and am trying to use it on the=
=20
example from the=20
quick start guide:
#include <stdlib.h>
void f(void) {
int* x =3D malloc(10 * sizeof(int));
x[10] =3D 0; // problem 1: heap block overrun
} // problem 2: memory leak -- x not freed
int main(void) {
f();
return 0;
}
I use gcc 3.2.2 to compile:
% gcc -g test.c
When I invoke valgrind, the output (a lot of it) seems to be correct,
but the line numbers are missing. How come?
% valgrind a.out
<quote>
=3D=3D7772=3D=3D Invalid write of size 4
=3D=3D7772=3D=3D at 0x8048489: ???
=3D=3D7772=3D=3D by 0x80484AA: ???
=3D=3D7772=3D=3D by 0x1B91F62C: __libc_start_main (in
/lib/libc-2.3.2.so<http://2.3.2.so>
)
=3D=3D7772=3D=3D by 0x8048398: ???
=3D=3D7772=3D=3D Address 0x1BA384F0 is 0 bytes after a block of size 40 all=
oc'd
=3D=3D7772=3D=3D at 0x1B900534: malloc (vg_replace_malloc.c:130)
=3D=3D7772=3D=3D by 0x804847C: ???
=3D=3D7772=3D=3D by 0x80484AA: ???
=3D=3D7772=3D=3D by 0x1B91F62C: __libc_start_main (in
/lib/libc-2.3.2.so<http://2.3.2.so>
)
=3D=3D7772=3D=3D by 0x8048398: ???
</quote>
Cheers
Jesper
|
|
From: Nicholas N. <nj...@cs...> - 2005-06-10 04:41:47
|
On Sun, 5 Jun 2005, Jesper Olsen wrote: > When I invoke valgrind, the output (a lot of it) seems to be correct, > but the line numbers are missing. How come? > > % valgrind a.out > <quote> > ==7772== Invalid write of size 4 > ==7772== at 0x8048489: ??? > ==7772== by 0x80484AA: ??? > ==7772== by 0x1B91F62C: __libc_start_main (in > /lib/libc-2.3.2.so<http://2.3.2.so> > ) > ==7772== by 0x8048398: ??? > ==7772== Address 0x1BA384F0 is 0 bytes after a block of size 40 alloc'd > ==7772== at 0x1B900534: malloc (vg_replace_malloc.c:130) > ==7772== by 0x804847C: ??? > ==7772== by 0x80484AA: ??? > ==7772== by 0x1B91F62C: __libc_start_main (in > /lib/libc-2.3.2.so<http://2.3.2.so> > ) > ==7772== by 0x8048398: ??? > </quote> Valgrind is unable to find any debug/symbol information here, not even module names. That sometimes happens when a shared object is unloaded, but that shouldn't happen in this case. What does the output of "nm a.out" look like? N |
|
From: Jesper O. <jes...@gm...> - 2005-06-10 13:50:50
|
On 6/10/05, Nicholas Nethercote <nj...@cs...> wrote: >=20 > On Sun, 5 Jun 2005, Jesper Olsen wrote: >=20 > > When I invoke valgrind, the output (a lot of it) seems to be correct, > > but the line numbers are missing. How come? > > >=20 Thanks for taking a look at this Nicholas. In my first post I only quoted part of the output from valgrind - below is= =20 the whole thing, which on my system seems to be more verbose than it should be... -Jesper % uname -a Linux jesperolsen.co.uk <http://jesperolsen.co.uk>=20 2.4.20-021stab028.3.777-enterprise #1 SMP Wed Feb 2 21:08:59 MSK 2005 i686= =20 i686 i386 GNU/Linux % nm a.out 08049424 D _DYNAMIC 08049500 D _GLOBAL_OFFSET_TABLE_ 08048410 R _IO_stdin_used w _Jv_RegisterClasses 080494f0 d __CTOR_END__ 080494ec d __CTOR_LIST__ 080494f8 d __DTOR_END__ 080494f4 d __DTOR_LIST__ 08048414 r __EH_FRAME_BEGIN__ 08048414 r __FRAME_END__ 080494fc d __JCR_END__ 080494fc d __JCR_LIST__ 08049518 A __bss_start 08049418 D __data_start 080483cc t __do_global_ctors_aux 080482c0 t __do_global_dtors_aux 0804941c D __dso_handle 08049418 A __fini_array_end 08049418 A __fini_array_start w __gmon_start__ 08049418 A __init_array_end 08049418 A __init_array_start 08048398 T __libc_csu_fini 08048368 T __libc_csu_init U __libc_start_main@@GLIBC_2.0 08049518 A _edata 0804951c A _end 080483f0 T _fini 0804840c R _fp_hw 08048230 T _init 08048278 T _start 0804829c t call_gmon_start 08049518 b completed.1 08049418 W data_start 08048328 T f 080482fc t frame_dummy 0804834c T main U malloc@@GLIBC_2.0 08049420 d p.0 % valgrind a.out =3D=3D10076=3D=3D Memcheck, a memory error detector for x86-linux. =3D=3D10076=3D=3D Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward = et al. =3D=3D10076=3D=3D Using valgrind-2.4.0, a program supervision framework for= =20 x86-linux. =3D=3D10076=3D=3D Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward = et al. =3D=3D10076=3D=3D For more details, rerun with: -v =3D=3D10076=3D=3D =3D=3D10076=3D=3D Conditional jump or move depends on uninitialised value(s= ) =3D=3D10076=3D=3D at 0x1B8ECD05: ??? =3D=3D10076=3D=3D by 0x1B8E542F: ??? =3D=3D10076=3D=3D by 0x1B8F0BEF: ??? =3D=3D10076=3D=3D by 0x1B8E4CF4: ??? =3D=3D10076=3D=3D by 0x1B8E4A86: ??? =3D=3D10076=3D=3D =3D=3D10076=3D=3D Conditional jump or move depends on uninitialised value(s= ) =3D=3D10076=3D=3D at 0x1B8ECD4F: ??? =3D=3D10076=3D=3D by 0x1B8E542F: ??? =3D=3D10076=3D=3D by 0x1B8F0BEF: ??? =3D=3D10076=3D=3D by 0x1B8E4CF4: ??? =3D=3D10076=3D=3D by 0x1B8E4A86: ??? =3D=3D10076=3D=3D =3D=3D10076=3D=3D Conditional jump or move depends on uninitialised value(s= ) =3D=3D10076=3D=3D at 0x1B8EC54A: ??? =3D=3D10076=3D=3D by 0x1B8ECBF1: ??? =3D=3D10076=3D=3D by 0x1B8E546B: ??? =3D=3D10076=3D=3D by 0x1B8F0BEF: ??? =3D=3D10076=3D=3D by 0x1B8E4CF4: ??? =3D=3D10076=3D=3D by 0x1B8E4A86: ??? =3D=3D10076=3D=3D =3D=3D10076=3D=3D Conditional jump or move depends on uninitialised value(s= ) =3D=3D10076=3D=3D at 0x1B8EC54E: ??? =3D=3D10076=3D=3D by 0x1B8ECBF1: ??? =3D=3D10076=3D=3D by 0x1B8E546B: ??? =3D=3D10076=3D=3D by 0x1B8F0BEF: ??? =3D=3D10076=3D=3D by 0x1B8E4CF4: ??? =3D=3D10076=3D=3D by 0x1B8E4A86: ??? =3D=3D10076=3D=3D =3D=3D10076=3D=3D Conditional jump or move depends on uninitialised value(s= ) =3D=3D10076=3D=3D at 0x1B8ECD4F: ??? =3D=3D10076=3D=3D by 0x1B8E546B: ??? =3D=3D10076=3D=3D by 0x1B8F0BEF: ??? =3D=3D10076=3D=3D by 0x1B8E4CF4: ??? =3D=3D10076=3D=3D by 0x1B8E4A86: ??? =3D=3D10076=3D=3D =3D=3D10076=3D=3D Invalid write of size 4 =3D=3D10076=3D=3D at 0x8048344: ??? =3D=3D10076=3D=3D by 0x8048360: ??? =3D=3D10076=3D=3D by 0x1B91F62C: __libc_start_main (in /lib/libc-2.3.2.so<http://2.3.2.so> ) =3D=3D10076=3D=3D by 0x8048298: ??? =3D=3D10076=3D=3D Address 0x1BA38050 is 0 bytes after a block of size 40 al= loc'd =3D=3D10076=3D=3D at 0x1B900534: malloc (vg_replace_malloc.c:130) =3D=3D10076=3D=3D by 0x8048337: ??? =3D=3D10076=3D=3D by 0x8048360: ??? =3D=3D10076=3D=3D by 0x1B91F62C: __libc_start_main (in /lib/libc-2.3.2.so<http://2.3.2.so> ) =3D=3D10076=3D=3D by 0x8048298: ??? =3D=3D10076=3D=3D =3D=3D10076=3D=3D ERROR SUMMARY: 14 errors from 6 contexts (suppressed: 0 f= rom 0) =3D=3D10076=3D=3D malloc/free: in use at exit: 40 bytes in 1 blocks. =3D=3D10076=3D=3D malloc/free: 1 allocs, 0 frees, 40 bytes allocated. =3D=3D10076=3D=3D For counts of detected errors, rerun with: -v =3D=3D10076=3D=3D searching for pointers to 1 not-freed blocks. =3D=3D10076=3D=3D checked 57344 bytes. =3D=3D10076=3D=3D =3D=3D10076=3D=3D LEAK SUMMARY: =3D=3D10076=3D=3D definitely lost: 40 bytes in 1 blocks. =3D=3D10076=3D=3D possibly lost: 0 bytes in 0 blocks. =3D=3D10076=3D=3D still reachable: 0 bytes in 0 blocks. =3D=3D10076=3D=3D suppressed: 0 bytes in 0 blocks. =3D=3D10076=3D=3D Use --leak-check=3Dfull to see details of leaked memory. |
|
From: James B. <ja...@ha...> - 2005-06-10 14:08:25
|
On Fri, 2005-06-10 at 16:50 +0300, Jesper Olsen wrote: > On 6/10/05, Nicholas Nethercote <nj...@cs...> wrote: > On Sun, 5 Jun 2005, Jesper Olsen wrote: > > When I invoke valgrind, the output (a lot of it) seems to be > > correct, but the line numbers are missing. How come? Do you have any spaces in the path to the executable? I seem to remember that this can confuse valgrind. If the KDE Bugzilla was working at the moment I could point you to the bug number for this ... Cheers, James. |
|
From: Jesper O. <jes...@gm...> - 2005-06-11 04:47:44
|
On 6/10/05, James Begley <ja...@ha...> wrote: >=20 > On Fri, 2005-06-10 at 16:50 +0300, Jesper Olsen wrote: > > On 6/10/05, Nicholas Nethercote <nj...@cs...> wrote: > > On Sun, 5 Jun 2005, Jesper Olsen wrote: > > > When I invoke valgrind, the output (a lot of it) seems to be > > > correct, but the line numbers are missing. How come? >=20 > Do you have any spaces in the path to the executable? I seem to > remember that this can confuse valgrind. If the KDE Bugzilla was No, not if I understand you correctly. The executable is in the current=20 directory: valgrind ./a.out -Jesper |