This is the mail archive of the glibc-linux@ricardo.ecn.wfu.edu mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Malloc's Behavior


>>>>> 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]