Xref: utzoo comp.sys.ibm.pc.programmer:511 comp.sys.ibm.pc:46870 Path: utzoo!dciem!nrcaer!sce!cognos!jimp From: jimp@cognos.UUCP (Jim Patterson) Newsgroups: comp.sys.ibm.pc.programmer,comp.sys.ibm.pc Subject: Re: File buffer trashing data? Message-ID: <8108@cognos.UUCP> Date: 20 Mar 90 14:04:40 GMT References: <1990Mar19.054020.13581@Neon.Stanford.EDU> Reply-To: jimp@cognos.UUCP (Jim Patterson) Followup-To: comp.sys.ibm.pc.programmer Organization: Cognos Inc., Ottawa, Canada Lines: 17 In article <1990Mar19.054020.13581@Neon.Stanford.EDU> minakami@Neon.Stanford.EDU (Michael K. Minakami) writes: >I'm trying to debug a program and came across something unusal: fwrite() >is changing the contents of an array. The array has memory calloc'ed >for it at the beginning of the program, and when fwrite() is called it >trashes everything started at array+4. It sounds like someone has free'd your array before you're done with it, and when you opened the file later, the buffer stdio uses was given the area previously free'd. If you put a breakpoint in free you might catch the offender. This might also happen without an actual free if somehow you've corrupted the free list that malloc/free maintain. -- Jim Patterson Cognos Incorporated UUCP:decvax!utzoo!dciem!nrcaer!cognos!jimp P.O. BOX 9707 PHONE:(613)738-1440 3755 Riverside Drive Ottawa, Ont K1G 3Z4