Re: Memory problems
Re: Memory problems
- Subject: Re: Memory problems
- From: email@hidden
- Date: Thu, 21 Mar 2002 14:41:24 -0800
I was wondering if the following error message meant anything to
anybody:
*** malloc[7835]: error for object 0x1d034f0: Incorrect check sum for
freed
object - object was probably modified after beeing freed; break at
szone_error
If anyone knows what could be causing this, let me know. If you need
more
details to diagnose, let me know as well. Thanks!
Sounds to me like... a freed object was probably modified after being
freed. :->
In practice, this means one of two things. Either somebody is keeping
and using a pointer to a malloced block after it is freed, or somebody
is setting memory in a freed block by "overrunning" some other block or
otherwise misusing a valid pointer.
You can, as the log suggests, set a breakpoint at szone_error to break
in gdb at the point this is detected. That will almost certainly be
well downstream of where it actually *happened*, though.
My recommendation would be to look first for an error of the first
kind (somebody keeping a pointer to a block that has been freed). When
you free a block, be sure to set all pointers referencing that block to
NULL to avoid this kind of accident. If you're quite certain this isn't
the problem, then you have to start looking for a problem of the second
kind, which can be much harder.
There are some facilities provided to help debug problems like this --
guard zones/pages, ways to make the malloc zone get checked more
frequently / on demand, etc. The man pages and other documentation on
malloc and the MallocDebug tool ought to help you out with these things;
there's probably also a good deal of chat about such things in the
archives, you might just search of "malloc".
Good luck.
Ben Haller
Stick Software
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.