Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find infinite loop in progress?

Is there a way to find out the current execution of the code to find out the infinite loop?

I have the application running with the current source. I'm attached with the visual studio debugger. I just need to know where the code is currently at so that I can debug it further.

like image 349
jdelator Avatar asked May 04 '10 17:05

jdelator


People also ask

Can an infinite loop be detected?

While most infinite loops can be found by close inspection of the code, there is no general method to determine whether a given program will ever halt or will run forever; this is the undecidability of the halting problem.

How do you get infinite loop?

Usually, an infinite loop results from a programming error - for example, where the conditions for exit are incorrectly written. Intentional uses for infinite loops include programs that are supposed to run continuously, such as product demo s or in programming for embedded system s.

How do I get out of endless loop?

In order to come out of the infinite loop, we can use the break statement. Let's understand through an example. In the above code, we have defined the while loop, which will execute an infinite number of times until we press the key 'n'. We have added the 'if' statement inside the while loop.

What is an example of an infinite loop?

An infinite loop occurs when a condition always evaluates to true. Usually, this is an error. For example, you might have a loop that decrements until it reaches 0.


1 Answers

If you're running it from Visual Studio, you can pause the execution with the 'pause' button in the code page. The current line will be in green.

like image 57
David Brunelle Avatar answered Oct 05 '22 14:10

David Brunelle