An "infinite loop" is a loop in which the exit criteria are never satisfied; such a loop would perform a potentially infinite number of iterations of the loop body. The general problem of determining whether the execution of a loop with given preconditions will result in an infinite loop is undecidable; in other words, there is no algorithm to determine whether an execution of a loop will eventually terminate. This is known as the halting problem.
Questions tagged [infinite-loop]
3528 questions
10
votes
4 answers
Angular Infinite $digest Loop
I am working on a site where you can search a food, and see if its a fruit, a vegetable, or neither (because I'm bored). I decided to use Angular, even though I'm pretty new to it.
I started getting this error: $rootScope:infdig
Infinite $digest…

Addison
- 3,791
- 3
- 28
- 48
10
votes
5 answers
Why is there an infinite loop in my program?
int main(void)
{
int i;
int array[5];
for (i = 0; i <= 20; i++)
array[i] = 0;
return 0;
}
Why is the above code stuck in an infinite loop?

daNullSet
- 669
- 2
- 6
- 16
10
votes
3 answers
Infinite loop in java.util.HashMap
I have some Vaadin code blocking very often here, and I have no idea what the problem can be:
Thread 7892: (state = IN_JAVA)
- java.util.HashMap.getEntry(java.lang.Object) @bci=61, line=349 (Compiled frame; information may be imprecise)
-…

blueFast
- 41,341
- 63
- 198
- 344
9
votes
6 answers
Is it a sin to use infinite recursion for infinite loops in Python?
This question is more about curiosity than utility. If I'm writing a function that's supposed to run for ever, for instance a daemon, how would Python handle it if I called the function again from the end of the function?
def daemonLoop():
#…

Hubro
- 56,214
- 69
- 228
- 381
9
votes
3 answers
HAL_Delay() stuck in a infinite loop
I am stuck with HAL_Delay() function. When i call this function HAL_Delay() , control stuck in infinite loop.
While searching for the problem, I found this
http://www.openstm32.org/forumthread2145#threadId2146
In this particular comment which states…

Devjeet Mandal
- 345
- 1
- 4
- 23
9
votes
5 answers
laravel artisan use of undefined constant STDIN - assumed 'STDIN' infinite loop
I am using laravel 5.6 and have the problem, when I use the command "php artisan vendor:publish" in the console, I get the following error:
[ERROR] Use of undefined constant STDIN - assumed 'STDIN'
Which provider or tag's files would you like to…

Josef
- 229
- 1
- 2
- 9
9
votes
2 answers
Why is Ruby's loop command slower than while true?
Ruby has a built-in loop command that executes the block following it forever (or until stopped by break). However, when comparing it against the functionally similar while true, it is significantly slower:
require "benchmark/ips"
NUMBER =…

Mangara
- 1,116
- 1
- 10
- 23
9
votes
2 answers
Custom iterator to infinitely iterate collection in a loop mode
I am looking for iterator to infinitely iterate collection in a loop mode. So that when end index of collection is reached, then iterator should return element at start index.
The following solution seems working, but I hope it can be made in a…

Vlad
- 6,402
- 1
- 60
- 74
9
votes
7 answers
Swift Infinite Fade in and Out Loop
How can I make a effect in swift similar to this:
I want the animation to loop forever.

Alex Safayan
- 2,921
- 4
- 17
- 22
9
votes
4 answers
Android : Implementation of two way Endless Viewpager
What I want:
I have been trying to implement two directional Endless viewpager in Android, Left to Right & Right to Left
What I did:
I have implemented Endless viewpager adapter, it works fine for right to left direction, I have set current item…

Hiren Patel
- 52,124
- 21
- 173
- 151
9
votes
1 answer
Proving False with negative inductive types in Coq
The third chapter of CPDT briefly discusses why negative inductive types are forbidden in Coq. If we had
Inductive term : Set :=
| App : term -> term -> term
| Abs : (term -> term) -> term.
then we could easily define a function
Definition uhoh (t…

user287393
- 1,221
- 8
- 13
9
votes
5 answers
Java infinite loop performance
I have a Thread that only has to work when a certain circumstance comes in. Otherwise it just iterates over an empty infinite loop:
public void run() {
while(true) {
if(ball != null) {
// do some Calculations
}
…

SimonH
- 1,385
- 15
- 35
9
votes
2 answers
Why Does Test Condition of "for(;;)" Succeed?
Insomuch as I understand "for(;;)" has no initial condition, no test condition and no increment condition, and therefore loops forever, I am curious why the test condition succeeds each loop.
Does the empty expression ";" evaluate as true in C? Or…

iokevins
- 1,427
- 2
- 19
- 29
9
votes
3 answers
Infinite loop in binary search
I am trying to implement binary search with the following function:
def buggy_binary_search(input, key):
low = 0
high = len(input)-1
mid = (low + high)/2
while low <= high:
if input[mid] == key:
return mid
…

Ramya
- 313
- 1
- 4
- 10
9
votes
6 answers
Looping a PHP Script
I've got a PHP script that checks a directory and deletes any files not modified within 15 seconds (It's for a game).
My problem is how to get this script to run all the time. I set up a cron job to run every 10 minutes and then in the PHP script I…

William W
- 1,776
- 6
- 21
- 40