Other Parts Discussed in Thread: C2000WARE, SYSCONFIG
The application report SPRA820 suggests a method to detect a stack overflow, but I'm doubtful about its real effectiveness.
In that application is defined a small window (8 words), monitored by a watchpoint, near the end of the valid stack (lower addresses) - see section 3.1 in the above document. When some code starts clobbering the monitored space, just because the stack pointer is going that much down the area, some event would be triggered to signal it. At first sight, this can appear as a good enough solution, but I doubt this holds (always) true when calling a function like this:
int foo(int x)
{
int buffer[100];
int var = x;
...
}
If `buffer
` happens to be allocated starting before the monitoring window and ending after it, and is never completely written, there's no guarantee that it will trigger the overflow. At the same time, the `var
` assignment alone can modify data in an unexpected area (well below the stack area). This function can even return successfully after it has destroyed valuable data, without leaving any trace.
Is this consideration founded as it looks to me?