MH Tay wrote:
> Ummm... No always predictable...
> => Recursive function calls
> => Nested interrupt service routine
> Regards
I am not sure who or what that comment was directed at, but I assume it
was my statement; "there are many more undetectable and likely stack
overflow possibilities"? I should qulaify that:
It is possible to detect 'worse case' stack depth by extensive static
analysis. In trivial applications this could be done manually. In
complex applications it would require tool support. I am not aware of
any compiler that provides such support. In practice, the 'worse case'
conditions are never met. For example say that a level of recursion were
determined by some sensor input that was of known limited range, if the
value was held in an unsigned int for example, a static analysis tool
would assume 'worse case' that the value could take 2^32 possible values
- it might predict a stack overflow that cannot occur in the real world.
Moreover, the problem is much more complex even than that. In most
simple systems, the different stacks are used for the interrupt and
exception handler contexts, and if an RTOS is used, each task has a
stack. The stacks for each task are allocated at runtime from either the
heap or from static memory.
Clifford