I have recently spent 2 days debugging a crash of the program that turned out to be caused by exhaustion of the boost::coroutine stack (which is by default of a very moderate size - 128k).
After I increased the stack size to 1MB, the crash went away. However I feel that this is not the solution as it just pushes the problem further.
What I'd like to do is to show the user an error message telling that the input is too big.
I have researched for ways to do this, and only using segmented stack seemed promising, however they only work on Linux and I need my code to work on Windows as well.
Is there maybe some way to predict that the coroutine's stack is about to be overflown, or maybe install a signal handler to fail gracefully in this case?
boost::fiber
on Linux -- and it didn't work. I did, in addition to increasing the stack size for my fibers, end up giving them "protected" stacks in the hope that it might lead to an easier-to-locate crash when it actually happens instead of just trashing random memory. While the code runs on Windows as well, I've not tested the protected stacks so I don't know whether it works there or not.