How to stop infinite loop in Unity?

I write two function: A function need call B function, and B function need call A function.

so Unity goto “not response”…

In real scence, My function has complex more, many function and event can call self or other, if find infinite loop, I can’t fast find error point.

Now, I very need know: How to stop infinite loop in Unity? (don’t stop Unity with “windows process manager”) and thorough step: How to search infinite loop in script.


Windows 10;

Unity 2019.4.19 f1c1;

Rider or VS2019.

How to stop infinite loop in Unity?
Never, ever, architecture a situation where two functions can call each other ad infinitum. Especially on purpose. That’s all there is to it, end of story.
In cases where you don’t yet know where inf loop took you by surprise: backup your code and start understanding deeply code you wrote last few days, maybe comment out part of it so you can pinpoint what are conditions for it to happen. Then delete that code completely and rewrite it once again but in a way that makes infinite loops impossible.