[fpc-pascal] detecting recursive loops

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Sun May 6 11:13:58 CEST 2018


On 05/05/18 21:15, James Richters wrote:
> 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?

I occasionally put entry/exit counters on functions that I suspect are 
going to be a problem, InterlockedIncrement() etc. You can obviously 
have your code check that as a verification of sanity, or pick up a haig 
value using a conditional breakpoint.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-pascal mailing list