On 9/22/20 5:58 PM, Bruno Haible wrote:
It sounds what you want is a function that returns the stack bounds, in such a
way that every recursion step in a recursive function call the code can ask
"am I close to the stack bound? do I need to stop recursing?"

That shouldn't be necessary, except for functions where GCC can't prove that their activation records are small (and these exceptions should be quite rare at runtime).

I am thinking of some combination of gcc -fstack-check and/or -fstack-clash-protection and/or related ideas (not that I've looked into all the details). That is, I'm expecting help from the hardware, the kernel, and from GCC. Stack-exhaustion checking should "just work". I realize it's a nontrivial ask.

Reply via email to