Re: Stack Overflow Detection
- From: Tomás Ó hÉilidhe <toe@xxxxxxxxxxx>
- Date: Fri, 30 May 2008 08:11:44 -0700 (PDT)
On May 30, 3:51 pm, "Richard Phillips" <raphill...@xxxxxxxxxxxx>
wrote:
Hello all,
I'm thinking about implementing the above in a system I'm working on, does
anyone have a good strategy for doing this?
One possibility is having an area of RAM (beyond the stack "area") filled
with known data, if any of that data gets trashed then assume the stack has
overflowed. What are the pros and cons of this?
Another idea is to actually watch the SP, but one drawback is if I check
this at a predefined point in the code, then it's possible the worst case
scenario will occur between checks?
Any better ideas?
Obviously if the stack overflows then that's a sign of flaw in the
programming, so really you're trying to implement a system that
accommodates buggy programming and just peforms a "salvage operation"
by killing the program before it can do any damage... do I understand
correctly?
To my knowledge there are two symptoms of stack overflow:
1) The stack pointer being greater than it should be
2) Data after the stack pointer getting changed
As you've said, you can't really rely on the first one because it
could go forward and then move back to a safe area. As for the second,
well it has a very good chance of working, but there's still a 1 in
256 chance that the corrupt byte will be exactly equal to the "test
value" :-P
Assuming that I'm right in saying that you'll just kill the program if
the stack overflows, what will be the benefit of this? Will it stop
the Green Laser of Death from being turned on, or will it stop
permanent storage from being corrupted or something like that?
.
- Follow-Ups:
- Re: Stack Overflow Detection
- From: Robert Adsett
- Re: Stack Overflow Detection
- From: Richard Phillips
- Re: Stack Overflow Detection
- References:
- Stack Overflow Detection
- From: Richard Phillips
- Stack Overflow Detection
- Prev by Date: Re: Driving tri-state LED matrix
- Next by Date: Re: Driving tri-state LED matrix
- Previous by thread: Stack Overflow Detection
- Next by thread: Re: Stack Overflow Detection
- Index(es):
Relevant Pages
|