Re: Stack Overflow Detection



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?
.



Relevant Pages

  • Re: C: The Complete Meta-Nonsense
    ... such as telling Schildt not to say that C negatives ... In other words, you don't care about truth, you care only about status. ... But note that even CREATING those bug reports is often programming beyond ... was frightened by a stack when he was in her womb and who hates ...
    (comp.lang.c)
  • Re: Stack Overflow Detection
    ... One possibility is having an area of RAM (beyond the stack "area") ... Obviously if the stack overflows then that's a sign of flaw in the ... accommodates buggy programming and just peforms a "salvage operation" ... 256 chance that the corrupt byte will be exactly equal to the "test ...
    (comp.arch.embedded)
  • Re: Forth Frustrations
    ... I was working on an interface to my new window system in Ficl. ... I found it extremely frustrating to juggle around data on the stack, such as 2 RGBA color components when building a gradient. ... I've been accused of programming C in Forth, as if that's somehow terrible, but I digress... ... I was thinking that indexed keyed arrays might be an approach, or a completely different language. ...
    (comp.lang.forth)
  • Re: Statement on Schildt submitted to wikipedia today
    ... programming, after thirty years, I teach English and creative writing ... but the stack has priority because you can write slow OSen without ... The student does not need to learn to think at either, ... People who didn't read Schildt know that there are different computer ...
    (comp.lang.c.moderated)
  • Re: Is Delphi for Win32 still mainstream?
    ... A MODULAR PROGRAMMING LESSON FOR ALL DELPHI PROGRAMMERS ... There is a little niche community out there that makes use of the stack, not just heap - so that we don't have to create and free every darned thing in the universe. ... I am bringing back stack objects and records into my programming. ... No over engineering. ...
    (borland.public.delphi.non-technical)