|
From: Mahadevaswamy.Lingaiah <Mah...@de...> - 2005-03-24 08:45:29
|
This is my simple program to check the memory leak condition. When I ran=
this program using the command shown below, I received the segmentation=
error with no memory leak. Please help me in rectifying this problem.
=0D
/* sat.c */
=0D
#include <stdio.h>
=0D
int main()
{
char *p;
// Allocation #1 of 19 bytes
p =3D (char *) malloc(19);
=0D
// Allocation #2 of 12 bytes
p =3D (char *) malloc(12);
free(p);
=0D
// Allocation #3 of 16 bytes
p =3D (char *) malloc(16);
=0D
return 0;
}
=0D
$ gcc -o sat -g sat.c
$ valgrind --tool=3Dmemcheck --leak-check=3Dyes --show-reachable=3Dyes=
--num-callers=3D20 --track-fds=3Dyes --trace-children=3Dyes -v ./sat
=0D
=3D=3D2943=3D=3D Memcheck, a memory error detector for x86-linux.
=3D=3D2943=3D=3D Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward=
et al.
=3D=3D2943=3D=3D Using valgrind-2.2.0, a program supervision framework for=
x86-linux.
=3D=3D2943=3D=3D Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward=
et al.
=3D=3D2943=3D=3D Valgrind library directory: /usr/local/lib/valgrind
=3D=3D2943=3D=3D Command line
=3D=3D2943=3D=3D ./sat
=3D=3D2943=3D=3D Startup, with flags:
=3D=3D2943=3D=3D --tool=3Dmemcheck
=3D=3D2943=3D=3D --leak-check=3Dyes
=3D=3D2943=3D=3D --show-reachable=3Dyes
=3D=3D2943=3D=3D --num-callers=3D20
=3D=3D2943=3D=3D --track-fds=3Dyes
=3D=3D2943=3D=3D -v
=3D=3D2943=3D=3D Contents of /proc/version:
=3D=3D2943=3D=3D Linux version 2.4.18-6mdk (qui...@bi...)=
(gcc version 2.96 20000731 (Mandrake Linux 8.2 2.96-0.76mdk)) #1 Fri Mar=
15 02:59:08 CET 2002
=3D=3D2943=3D=3D Reading syms from=
/test/guest/memoryleak/valgrind-2.2.0/coregrind/sat (0x8048000)
=3D=3D2943=3D=3D Reading syms from /lib/ld-2.2.4.so (0x1B8E4000)
=3D=3D2943=3D=3D Reading syms from /usr/local/lib/valgrind/stage2=
(0xB0000000)
=3D=3D2943=3D=3D Reading syms from /lib/ld-2.2.4.so (0xB1000000)
=3D=3D2943=3D=3D Reading syms from /lib/libdl-2.2.4.so (0xB1024000)
=3D=3D2943=3D=3D object doesn't have a symbol table
=3D=3D2943=3D=3D object doesn't have any debug info
=3D=3D2943=3D=3D Reading syms from /lib/libc-2.2.4.so (0xB1027000)
=3D=3D2943=3D=3D object doesn't have a symbol table
=3D=3D2943=3D=3D object doesn't have any debug info
=3D=3D2943=3D=3D Reading syms from=
/usr/local/lib/valgrind/vgskin_memcheck.so (0xB1300000)
=3D=3D2943=3D=3D Reading suppressions file:=
/usr/local/lib/valgrind/default.supp
=3D=3D2943=3D=3D REDIRECT soname:libc.so.6(__GI___errno_location) to=
soname:libpthread.so.0(__errno_location)
=3D=3D2943=3D=3D REDIRECT soname:libc.so.6(__errno_location) to=
soname:libpthread.so.0(__errno_location)
=3D=3D2943=3D=3D REDIRECT soname:libc.so.6(__GI___h_errno_location) to=
soname:libpthread.so.0(__h_errno_location)
=3D=3D2943=3D=3D REDIRECT soname:libc.so.6(__h_errno_location) to=
soname:libpthread.so.0(__h_errno_location)
=3D=3D2943=3D=3D REDIRECT soname:libc.so.6(__GI___res_state) to=
soname:libpthread.so.0(__res_state)
=3D=3D2943=3D=3D REDIRECT soname:libc.so.6(__res_state) to=
soname:libpthread.so.0(__res_state)
=3D=3D2943=3D=3D REDIRECT soname:libc.so.6(stpcpy) to=
*vgpreload_memcheck.so*(stpcpy)
=3D=3D2943=3D=3D REDIRECT soname:libc.so.6(strnlen) to=
*vgpreload_memcheck.so*(strnlen)
=3D=3D2943=3D=3D REDIRECT soname:ld-linux.so.2(stpcpy) to=
*vgpreload_memcheck.so*(stpcpy)
=3D=3D2943=3D=3D REDIRECT soname:ld-linux.so.2(strchr) to=
*vgpreload_memcheck.so*(strchr)
=3D=3D2943=3D=3D
=3D=3D2943=3D=3D Reading syms from /usr/local/lib/valgrind/vg_inject.so=
(0x1B8FB000)
=3D=3D2943=3D=3D Reading syms from=
/usr/local/lib/valgrind/vgpreload_memcheck.so (0x1B8FE000)
=3D=3D2943=3D=3D Reading syms from /lib/libc-2.2.4.so (0x1B915000)
=3D=3D2943=3D=3D object doesn't have a symbol table
=3D=3D2943=3D=3D object doesn't have any debug info
=3D=3D2943=3D=3D
=3D=3D2943=3D=3D Process terminating with default action of signal 11=
(SIGSEGV)
=3D=3D2943=3D=3D Bad permissions for mapped region at address 0x1B901489
=3D=3D2943=3D=3D at 0x1B8EE819: _dl_relocate_object=
(../sysdeps/i386/dl-machine.h:436)
=3D=3D2943=3D=3D by 0x1B8E5E64: dl_main (rtld.c:1239)
=3D=3D2943=3D=3D by 0x1B8F30B9: _dl_sysdep_start=
(../sysdeps/generic/dl-sysdep.c:208)
=3D=3D2943=3D=3D by 0x1B8E5801: _dl_start_final (rtld.c:263)
=3D=3D2943=3D=3D by 0x1B8E5657: _dl_start (rtld.c:216)
=3D=3D2943=3D=3D by 0x1B8E52B5: (within /lib/ld-2.2.4.so)
=3D=3D2943=3D=3D
=3D=3D2943=3D=3D FILE DESCRIPTORS: 3 open at exit.
=3D=3D2943=3D=3D Open file descriptor 2: /dev/pts/2
=3D=3D2943=3D=3D <inherited from parent>
=3D=3D2943=3D=3D
=3D=3D2943=3D=3D Open file descriptor 1: /dev/pts/2
=3D=3D2943=3D=3D <inherited from parent>
=3D=3D2943=3D=3D
=3D=3D2943=3D=3D Open file descriptor 0: /dev/pts/2
=3D=3D2943=3D=3D <inherited from parent>
=3D=3D2943=3D=3D
=3D=3D2943=3D=3D
=3D=3D2943=3D=3D ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6=
from 2)
--2943--
--2943-- supp: 3 _dl_init/ld-2.2.4.so(Cond)
--2943-- supp: 3 _dl_relocate_object/dl_main(Cond)
=3D=3D2943=3D=3D malloc/free: in use at exit: 0 bytes in 0 blocks.
=3D=3D2943=3D=3D malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
=3D=3D2943=3D=3D
=3D=3D2943=3D=3D No malloc'd blocks -- no leaks are possible.
--2943-- TT/TC: 0 tc sectors discarded.
--2943-- 1159 tt_fast misses.
--2943-- translate: new 1159 (22302 -> 287336; ratio 128:10)
--2943-- discard 0 (0 -> 0; ratio 0:10).
--2943-- chainings: 821 chainings, 0 unchainings.
--2943-- dispatch: 37447 jumps (bb entries); of them 2043 (5%) unchained.
--2943-- 13/1198 major/minor sched events.
--2943-- reg-alloc: 308 t-req-spill, 53278+2361 orig+spill uis,
--2943-- 6516 total-reg-rank
--2943-- sanity: 14 cheap, 1 expensive checks.
--2943-- ccalls: 4422 C calls, 49% saves+restores avoided (12738 bytes)
--2943-- 5718 args, avg 0.84 setup instrs each (1792 bytes)
--2943-- 0% clear the stack (13266 bytes)
--2943-- 2289 retvals, 25% of reg-reg movs avoided (1136 bytes)
proxy 2944 for tid 1 exited status -1, res 0
Segmentation fault
=0D
[guest@ECT_LINUX coregrind]$ uname -a
Linux ECT_LINUX 2.4.18-6mdk #1 Fri Mar 15 02:59:08 CET 2002 i686 unknown
=0D
=0D
***************************************************************************=
*************
Note: The information contained in this message may be privileged and=
confidential and thus protected from disclosure. If the reader of this=
message is not the intended recipient, or an employee or agent responsible=
for delivering this message to the intended recipient, you are hereby=
notified that any dissemination, distribution or copying of this=
communication is strictly prohibited. If you have received this=
communication in error, please notify us immediately by replying to the=
message and deleting it from your computer. Thank you.=0D
***************************************************************************=
************* |