I was having a very weird segfault that I eventually fixed today. It seems the problem was I was allocating a very large array on stack and that was causing the problem.
My question is, do you always get a SEGV signal on stack overflow? Is there any special signal that could alert there is a stack overflow problem?
I’m using g++ along with gdb.
The “signal” in the sense of Unix signals is apparently SEGV. 🙂 If you mean signal like using a diagnostic tool that will tell you when something bad is happening, you could try valgrind, but really, your system just told you. And knowing at compile time whether the stack will be overflowed is not possible, partly because the stack size limit is a runtime parameter, and besides I imagine if you knew what it would be a priori, you’d still be stuck with something like the Halting Problem.