Re: Stack Overflow Detection
- From: Tomás Ó hÉilidhe <toe@xxxxxxxxxxx>
- Date: Fri, 30 May 2008 11:32:43 -0700 (PDT)
On May 30, 4:37 pm, Vladimir Vassilevsky <antispam_bo...@xxxxxxxxxxx>
wrote:
The main problem with it is that you
never know for sure what is the maximum stack usage.
Are you sure about that? Would it not just be a case of determining
how much stack space each of the function's use, and then looking at
the logic of the program to see what could possibly be the deepest
level?
Even if there were recursive functions involved, they could still be
given a finite limit:
double RaiseToIntPower(double val,unsigned exp)
{
if (0 == exp) return 1;
if (1 == exp) return val;
return val * RaiseToIntPower(val,--exp);
}
For example the logic of the program my prevent "exp" from being more
than 7, or then again you could hardcode your own "if (exp > 7)"
within the function.
(Obviously it's a stupid idea to implement this function as a
recursive funciton, but it was an easy example to throw together for
the purposes of explanation.)
.
- Follow-Ups:
- Re: Stack Overflow Detection
- From: Niklas Holsti
- Re: Stack Overflow Detection
- From: Rich Webb
- Re: Stack Overflow Detection
- References:
- Stack Overflow Detection
- From: Richard Phillips
- Re: Stack Overflow Detection
- From: Vladimir Vassilevsky
- Stack Overflow Detection
- Prev by Date: Re: what is your take on evaluation boards and dev kits?
- Next by Date: Re: Driving tri-state LED matrix
- Previous by thread: Re: Stack Overflow Detection
- Next by thread: Re: Stack Overflow Detection
- Index(es):