Re: Tips for debugging stack smash?
Re: Tips for debugging stack smash?
- Subject: Re: Tips for debugging stack smash?
- From: David A Rowland <email@hidden>
- Date: Wed, 2 Aug 2006 10:45:41 -0700
At 1:32 PM -0400 8/2/06, Cameron Hayne wrote:
On 2-Aug-06, at 12:27 PM, Scott Ribe wrote:
Sigh... I'm smashing the stack, leaving things where XCode doesn't show any
useful info when it breaks.
Suggestions:
1) Look carefully at what is on the stack. Try to figure out what
those hex bytes might represent - that could give you a clue. If
there is a common pattern of hex bytes on the stack when the problem
occurs, maybe installing a conditional break point in gdb will allow
you to determine where the problem occurs.
2) Scan your code for functions whose return values are larger than
what would fit in a register - e.g. functions that return a struct
or object by value. Look carefully at those functions. I've some
times seen cases where the return statement was missing and, for
some reason that I don't understand, the compiler wasn't complaining.
It doesn't, and I forget all the reasons. I think it's because the
compiler cannot catch all possible "naked" exits, so it doesn't try.
But that should not cause a crash.
3) Turn on all warnings in gcc. Also try running 'lint' on your code.
4) Try divide & conquer techniques like commenting out half of your
code and seeing if the problem occurs.
--
Cameron Hayne
email@hidden
In particular, look for any arrays whose bounds might be exceeded.
Also check for uninitialized pointers or calculations on pointers
that aren't right.
David
_______________________________________________
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