How to avoid Segmentation Fault 11 on infinite recursion?


I am writing a simple interpreter using C++ and I need to throw exception on infinite recursion.
Currently the program falls with Segmentation fault 11.
Is there a method to avoid it?

Thank you,
Andrey Sharoyko.

You just have to hardcode in limits (avoid recursion as much as reasonable, reduce stack frame sizes, etc - but ultimately you’ll want counters in to bail out at very deep recursions, like Clang has).