Re: Stack Overflow Detection



Richard Phillips 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?

It is commonly used. You can fill the stack area with a known
value and check the highest level actually reached. You can
then double the amount of space for good measure. This is not
a guarantee, of course.

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?

Perform blackbox and whitebox testing, make sure all
paths are taken, you will have a better idea, but
still no guarantee.
.



Relevant Pages

  • Re: Writing a function to figure out if stack grows up or down
    ... standard doesn't guarantee that there's such a thing as "the stack". ... between two pointers to distinct objects (that are not part of some ... *most* C implementations do use a contiguous stack ...
    (comp.lang.c)
  • Re: [PATCH][6/8] Arch agnostic completely out of line locks / arm
    ... On Fri, 3 Sep 2004, Russell King wrote: ... There's no guarantee that LR will be the ... > Your best bet is to look at the get_wchancode which walks the stack ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: When to use automatic variables and when to use malloc
    ... stack unless I'm OK with the program crashing if there is not enough ... So if it would be OK to use the wrapper, it is OK to use VLA. ... The consequences of undefined behavior can be ... But the standard doens't guarantee this. ...
    (comp.lang.c)
  • Re: Decision with AQo on the bubble
    ... handed I guarantee his raising range in this spot is bigger than you ... good chunk of your stack, so it's either push or fold. ... think I push here, and I'd be surprised if he called. ... a fold isn't terrible if you think you can outplay ...
    (rec.gambling.poker)