Re: How to debug a corrupted stack
Re: How to debug a corrupted stack
- Subject: Re: How to debug a corrupted stack
- From: Ken Thomases <email@hidden>
- Date: Tue, 5 Aug 2008 23:14:03 -0500
On Aug 5, 2008, at 9:51 PM, Gerriet M. Denkmann wrote:
I have a document based app which works perfectly with -O0 or -O1
but crashes with -O2 or higher.
When the crash occurs the debugger comes up and says: "Previous
frame identical to this frame (corrupt stack?)"
When I try to step through the function (which is kind of difficult,
as the optimization has shuffled the lines a lot) at some time the
top frame of the stack gets duplicated.
The faulty method starts with:
NSString *path = @"/Users/gerriet/Desktop/some alias"; // error
with -O2
If it starts with:
NSString *path = @"/Users/gerriet/Desktop/some file"; // ok with -O2
then everything works perfectly.
When I comment out the place where the error seems to occur, it will
just occur at some earlier place.
So it is kind of difficult to see where and why the stack gets
corrupted.
Any help would be most welcome. I am completely run out of ideas and
spent already hours with this bug.
You don't say what kind of crash it is? EXC_BAD_ACCESS?
One thing to try is running the program with MallocDebug. When the
crash happens, use malloc_history to learn the history of the address
involved in the crash.
Another thing to try is enabling zombies.
You might also try turning on additional compilation warnings. When
optimization is turned on, the compiler can check more things because
it's doing data-flow analysis. It might find your error.
Finally, the last refuge of all programmers is to liberally sprinkle
printfs/NSLogs throughout the suspect code to see what's going on.
Similarly, you can put a breakpoint at some point you're sure is
before the problem starts and then step slowly through the code.
Good luck,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden