digitalmars.D.learn - Stack traces when stack overflow
- bearophile (10/10) Jun 01 2011 This crashes at runtime because of a stack overflow, without stack frame...
This crashes at runtime because of a stack overflow, without stack frame or
error message (DMD 2.053), no stack trace, or line number are shown:
int foo(int n) {
return n ? foo(n - 1) : 1;
}
void main() {
foo(100_000);
}
If you aren't running a debugger then receiving a nude crash is not so nice,
because in a larger program there are many functions that may be the cause of
such stack overflow. So is it possible to add some stack protection code (in
non-release mode only, if necessary) to receive a stack trace in this case?
Bye,
bearophile
Jun 01 2011








bearophile <bearophileHUGS lycos.com>