-3

How can I recover from stack overflow when I need to run recursive code of undetermined depth (and for example show and error when it's too large)?

What is the method with least overhead when using native (x86) stack?

zduny
  • 2,481
  • 1
  • 27
  • 49

1 Answers1

0

one simple way is to pass a variable into your recursive function that keeps track of how deep it is...

acushner
  • 9,595
  • 1
  • 34
  • 34
  • What can you do if you can't modify the function? Is it possible to catch stack overflow globally? – zduny Mar 10 '14 at 16:59
  • fair enough. in python you could do something with a wrapper that's better than my first answer. but globally is tough to define without a specific language. – acushner Mar 10 '14 at 20:29