[fpc-pascal] detecting recursive loops

James Richters james at productionautomation.net
Sat May 5 23:17:10 CEST 2018


I'm having an issue with one of my programs that I suspect is being caused by a recursive loop... in simplified form... something like this:

Procedure Proc1;
Begin
   Proc2;
End;
Procedure Proc2;
Begin
   Proc1;
End;

I ended up getting a runtime error and the report showed something like above, where I had a loop of the same 3 procedures calling each other over and over in sequence in a loop before the actual error.   Unfortunately I didn't take down all the information because I thought I could make it happen again.. but I haven't had the runtime error again... however under certain conditions sequences that normally happen very fast become very slow and I suspect it somehow is getting into this recursive loop again.

It's a very large very complicated program and trying figure out where this is happening is becoming quite a challenge.   I was wondering if there is some method of detecting these recursive loops, either during compilation, or is there some option that would force a runtime error if a loop of procedures happened.

Any ideas how to identify potential unintentional loops?




More information about the fpc-pascal mailing list