This is the mail archive of the
glibc-linux@ricardo.ecn.wfu.edu
mailing list for the glibc project.
Re: Malloc's Behavior
- To: "D. Sharma" <DhirajSharma at compuserve dot com>
- Subject: Re: Malloc's Behavior
- From: Andreas Jaeger <aj at suse dot de>
- Date: 26 Aug 2000 09:16:22 +0200
- Cc: Glib-Linux <glibc-linux at ricardo dot ecn dot wfu dot edu>
- References: <200008260013_MC2-B110-5A98@compuserve.com>
- Reply-To: glibc-linux at ricardo dot ecn dot wfu dot edu
>>>>> D Sharma writes:
D> I have a short program on Pentium, Red-Hat Linux that does the following:
D> malloc(100);
D> malloc(300000)
D> malloc(100);
D> In addition the pointers returned by malloc are printed. I find that
D> the first and the third calls give me pointers at about 130 MB, which seems
D> ok. The second gives me a pointer at 1.03 GB position, which seems
D> too high. After a few more allocations, the program get a setmentation
Read the libc manual, malloc uses mmap for large chunks.
D> fault in a subsequent call to malloc(). There is no call to free() or
D> realloc(). Any insight will be appreciated.
You've written beyond the allocated memory, thereby destroying
internal data of the malloc implementation.
Andreas
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj