Advertisement

infinite loop protection?

Started by May 26, 2002 03:33 PM
3 comments, last by Lode 22 years, 5 months ago
In some cases, if I make an infinite loop, and then run the program, the program just closes itself down without reason (it should be stuck in the loop, not close itself) Is this some sort of natural defence of the computer against infinite loops?
No, you''re doing something inside the loop that forces the program to close.
---visit #directxdev on afternet <- not just for directx, despite the name
Advertisement
quote: Original post by Lode
Is this some sort of natural defence of the computer against infinite loops?


There is no possible defense against infinite loops (even theoretical).
Cf. Halting Problem.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
>> There is no possible defense against infinite loops (even theoretical).

The halting problem just says that you cannot garantee for every case that you can determine for a program whether it has an infinite loop. But this does not imply that you cannot detect infinete loops for any programs at all and it is possible (although I don't know any debuggers that support it) to do some basic tests that may catch some infinite loops at run time - but not all loops can be catched this way of course.

[edited by - felonius on May 26, 2002 6:24:08 PM]
Jacob Marner, M.Sc.Console Programmer, Deadline Games
I solved it
It was a combination of circumstances that made it look as if the infinite loop was the problem, but the actual problem was that inside the loop I was reading from an array and incremented it each time. I didn''t know that reading 65536 array values went so quick, it looked as if the program closed immediatly...

Well thanks anyway

This topic is closed to new replies.

Advertisement