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: problem with malloc?


On Fri, 21 Apr 2000 fheitka@attglobal.net wrote:

> Date: Fri, 21 Apr 2000 11:02:20 -0400
> From: fheitka@attglobal.net
> Reply-To: glibc-linux@ricardo.ecn.wfu.edu
> To: glibc-linux@ricardo.ecn.wfu.edu
> Subject: problem with malloc?
> 
> I have written a C/C++ program that runs correctly using
> MS Visual C++ 5.0, IBM Visual Age C++ 4.0, and gnu gcc 2.95 on Sparc
> Solaris.  When I compile and try to run the same program on Linux the
> program dumps core with a seg. fault. evidently generated in glibc
> malloc.c.   Has anyone experienced a problem like this?

You probably corrupted memory by writing beyond either end of a dynamically
allocated object. That it works with two compilers is no proof of correctness.

You should rule out that this is not the case before writing to the glibc
mailing list. 

Debug your program using Electric Fence or a similar tool.

> The line in the code that precipitates the seg. fault. is simply
> allocating an pointer to make an array of pointers where the pointers
> point to identical structures.  The structures are allocated using
> Template code.  They are allocated using the "new" function.  I am trying
> to come up with a simple
> test program, but here is the gist of what I do.

The gist isn't good enough; you should produce a small program that reproduces
the error.


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