Re: Malloc debug when no Xcode?
Re: Malloc debug when no Xcode?
- Subject: Re: Malloc debug when no Xcode?
- From: Ken Thomases <email@hidden>
- Date: Thu, 20 Nov 2008 07:18:47 -0600
On Nov 20, 2008, at 4:28 AM, Matt Gough wrote:
A customer of ours has what looks like a double-free /memory smasher
bug (The stack trace ends in CFRelease).
Tomorrow morning I will be able to remotely login and try to
reproduce the problem. Unfortunately I don't know if he has
MallocDebug installed (unlikely) and I can't install anything myself.
Assuming that he doesn't have MallocDebug and that his Mac is
factory fresh with just OS updates on it (up to 10.5.5), is there
anything I can do from the terminal (or elsewhere) on that Mac to
help track this down?
The default malloc implementation in libSystem has debugging
facilities that don't require libMallocDebug or MallocDebug.app.
See 'man malloc' and 'man malloc_history'.
Typically, you'd set MallocScribble=1 and
MallocStackLoggingNoCompact=1 and then run the program. When
something unexpected happens involving a certain address, you would
use malloc_history to learn what had originally allocated (and perhaps
freed) the memory at that address. MallocScribble will help you with
certain kinds of accesses to uninitialized or freed memory.
One major complication is that, from what you say, the system probably
doesn't have gdb installed. In order to use malloc_history, the
process needs to be extant. If it crashes, then it's probably cleaned
up before you get a chance to analyze it. Normally, gdb would be
useful for catching the process in the middle of crashing. I'm not
sure what you can use to achieve a similar end. Perhaps you can write
a small stand-alone mini-debugger using the ptrace(2) facility just
for the purposes of freezing the program long enough to analyze.
Probably you can find source for such a mini-debugger for download
from the net.
Other techniques to try:
Setting NSZombieEnabled and CFZombieLevel may also help. Read the Mac
OS X Debugging Magic technote <http://developer.apple.com/technotes/tn2004/tn2124.html
> for many more techniques. (Note the caveat about CFZombieLevel and
custom allocators.)
Good luck,
Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden