# detect infinite loop in c program

Show 80 post(s) from this thread on one page
Page 2 of 2 First 12
• 10-01-2003
Hammer
>>i am terribly disappointed
Get over it :rolleyes:

Maybe this has something:
http://www.splint.org/
• 10-01-2003
Lynux-Penguin
there probably isn't a way to determine if it loops forever other than looking for things like
while(true)
for(;; )

or writing an ASM parser looking for a CONDITION in a loop, other than that, have fun ;)

-LC
• 10-01-2003
Salem
> i agree with u frnd that it was proved that its unsolvable in 1936.. but there are things that have been chg later..
Well mathematical proofs tend to stand for all time - I don't see any need to worry about how long ago it was. I don't for example worry that pythagoras' theorem a*a + b*b = c*c will be dis-proved in any near future.
• 10-01-2003
abhivyakat
FYI
I can tell some of the mathematical proofs which are lying in dust and they were considered words of GOD one time.. nyways thats not my purpose ... i was looking for a solution rather than tryin ppl knowlege of maths ... and u may call it bad but if i cant solve a problem , i get disappointed.....

looks like i have to write a parser where i will look for possible loops, iknow it wont be one covering all the cases but it wil do for the time being..
till then if someone can think of ny better sol. i will appreciate....
• 10-01-2003
Rog
One possible solution would be to have a reasonable time of execution/completion. The detector program would need to launch the program to be tested and continue to run concurrently. The detector would wait for the test program to return. While the test program executes, the detector uses the standard library function difftime() to compare the execution time of the test program to the reasonable time. If the test program does not return before the reasonable time is exceded the program is in an infinate loop.

This algorithm will only work for a specific input, but we know from Alan Turing's work that a solution that works for all inputs in not possible.

Rog
Show 80 post(s) from this thread on one page
Page 2 of 2 First 12