Path: utzoo!attcan!uunet!cs.utexas.edu!csd4.milw.wisc.edu!leah!rpi!pawl!shadow From: shadow@pawl.rpi.edu (Deven T. Corzine) Newsgroups: comp.sys.amiga.tech Subject: Re: Catching free memory violations Message-ID: Date: 29 Jul 89 11:12:47 GMT References: <7408@ecsvax.UUCP> <694@jc3b21.UUCP> Sender: usenet@rpi.edu Organization: Rensselaer Polytechnic Institute, Troy, NY Lines: 43 In-reply-to: fgd3@jc3b21.UUCP's message of 28 Jul 89 19:44:05 GMT On 28 Jul 89 19:44:05 GMT, fgd3@jc3b21.UUCP (Fabbian G. Dufoe) said: FGD> In article <7408@ecsvax.UUCP> utoddl@ecsvax.UUCP (Todd M. Lewis) FGD> asks about clearing free memory periodically as part of an effort FGD> to catch programs which use memory they don't own. This would FGD> work so long as you keep two things in mind. FGD> (1) The pointer to the next chunk of free memory occupies FGD> the first eight bytes of the current chunk. You can't free that. It IS free. You can't *zero* that. FGD> (2) If a program is writing on memory it hasn't allocated it FGD> may have clobbered one of those pointers. Consquently, you can't FGD> walk the system memory free list with any confidence. If it has clobbered the free list, the system is in a corrupt state anyhow, so you will lose anyhow. FGD> Those points aside, you could check whatever memory a chunk FGD> contains beyond the next chunk pointer to be sure that was zero. FGD> However, any application might allocate the memory, write on it, FGD> and free it without clearing it. So finding non-zero values in FGD> free memory wouldn't mean you had discovered a program which was FGD> writing on memory it didn't own. You missed the point entirely. The idea was to SetFunction() the FreeMem() function to zero memory *as it is freed*. Then either a SetFunction()ed AllocMem() function or some separate task/function could check the free list to make sure it is zeroed. If not, it is a sign of corruption. I think it's a fine idea, by the way. [we still need resource tracking...] Deven -- Deven T. Corzine Internet: deven@rpi.edu, shadow@pawl.rpi.edu Snail: 2214 12th Street, Troy, NY 12180 Phone: (518) 271-0750 Bitnet: deven@rpitsmts, userfxb6@rpitsmts UUCP: uunet!rpi!deven Simple things should be simple and complex things should be possible.