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, "Arthur H. Gold" wrote:
> Date: Fri, 21 Apr 2000 15:43:56 -0500
> To: glibc-linux@ricardo.ecn.wfu.edu
> From: "Arthur H. Gold" <agold@bga.com>
> Reply-To: glibc-linux@ricardo.ecn.wfu.edu
> Subject: Re: problem with malloc?
> 
> fheitka@attglobal.net wrote:
>
> Receiving a SIGSEGV during a malloc usually indicates that you've
> corrupted the heap in some way _before_ the call that generates the
> fault.
> Most likely you are either overrunning a buffer somewhere (messing with
> the heap's internal metadata) or freeing something incorrectly (causing
> a similar problem).
> SIGSEGVs like this are often the most difficult to track down because of
> the fact that by the time they occur, the code that actually _caused_
> the problem is long since gone.
> This might be a situation where Electric Fence or some other heap
> information/debugging library would be of help.

Got electric fence.  Thanks!

I found the problem.  It was a buffer overrun in strcpy.

My data file that my program reads was written by a fortran program 
I think.  Strlen seems to give the correct answer as far as actual number
of characters (20) , but strcpy tries to copy the whole line which is
62 characters.  Probably the length of the fortran record.

I put strncpy for strcpy and the program runs fine.

Thanks!

Fred


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