Detect Stack Overflow or Infinite Recursion

Hi, so I have a game that crashes at fairly random intervals, normally after about 20 minutes of play.
Since Unity is pretty good at catching and preventing most crashes with the exception of infinite recursion, I’m guessing that could be the cause. There is quite a lot of recursion in the game.
The problem is that the game is basically finished at this point, so its quite large with probably about 30 different pieces of quite complex recursive code and as far as I know Unity gives no feedback at all about either infinite recursion or stack overflows.

Does anyone have any idea how I could track this down?
I’m hoping that there’s some log file hidden away somewhere that contains more info when unity crashes that might be useful or some method to get feedback about how deep the stack currently is.

Anyone have any ideas?

There is a crash log - and a quick search will help you find it.

You’re going to need to sit down and rewrite your recursions to be safer - there’s no way to handle the error once it occurs.

Maybe you should build in a maximum recursion limit for testing. Work out roughly how many times you expect a piece of recursive code to run in a worst case scenario, double it and if it goes over that limit, break out of the loop and print an error with any info which might help you find out why it occurred.