Game Development Reference
In-Depth Information
Figure 23.4
Artist
'
s rendering of earwax blowing out of Mr. Mike
'
s ears.
Stack Corruption
Stack corruption is evil because it wipes evidence from the scene of the crime. Take a
look at this lovely code:
void StackTrasher()
{
char hello[10];
memset(hello, 0, 1000);
}
The call to memset() never returns, since it wipes the stack clean, including the
return address. The most likely thing your computer will do is break into some
crazy, codeless area
the debugger equivalent of shrugging its shoulders and leaving
you to figure it out for yourself. Stack corruptions almost always happen as a result of
sending bad data into an otherwise trusted function, like memset() . Again, you must
have a reasonable set of steps you can follow to reproduce the error.
Begin your search by eliminating subsections of code, if you can. Set a breakpoint at the
highest level of code in your main loop and step over each function call. Eventually, you
should be able to find a case where stepping over a function call will cause the crash.
Begin your experiment again, only this time step into the function and narrow the list
of perpetrators. Repeat these steps until you ' ve found the call that causes the crash.
 
Search WWH ::




Custom Search