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
9
votes
6 answers
Scala while(true) type mismatch? Infinite loop in scala?
Why following code
def doSomething() = "Something"
var availableRetries: Int = 10
def process(): String = {
while (true) {
availableRetries -= 1
try {
return doSomething()
} catch {
case e: Exception => {
if…

TN.
- 18,874
- 30
- 99
- 157
8
votes
1 answer
Android bluetooth connection error (no bt sock found, scn 1) - infinite loop
I am facing the same problem as in a previous (and unanswered) question, I was hesitating to edit it, as I want to add a lot more information. So here is the related question : Android bluetooth connection fails (Error: no bt sock found, scn 1).
The…

fripon
- 101
- 10
8
votes
1 answer
Fast Repeat TakeWhile causes infinite loop
How can I make the following observable repeat until stream.DataAvailable is false?
Currently it looks like it never stops.
AsyncReadChunk and Observable.Return inside the Defer section make OnNext call then OnCompleted call.
When Repeat receives…

Samet S.
- 475
- 1
- 10
- 21
8
votes
4 answers
How do I handle an infinite list of IO objects in Haskell?
I'm writing a program that reads from a list of files. The each file either contains a link to the next file or marks that it's the end of the chain.
Being new to Haskell, it seemed like the idiomatic way to handle this is is a lazy list of…

rprospero
- 913
- 11
- 26
8
votes
1 answer
React Hook useEffect has missing dependencies: xxx. Either include them or remove the dependency array react-hooks/exhaustive-deps
I am making an api call from useEffect hook
function ChangePassword(props) {
const token = props.match.params.token;
const [state, setState] = useState({
password: "",
confirmPassword: "",
});
const [status,…

Parag Katoch
- 111
- 1
- 2
- 4
8
votes
4 answers
Is it possible to test a while True loop with pytest (I try with a timeout)?
I have a python function foo with a while True loop inside.
For background: It is expected do stream info from the web, do some writing and run indefinitely. The asserts test if the writing was done correctly.
Clearly I need it to stop sometime, in…

Newskooler
- 3,973
- 7
- 46
- 84
8
votes
4 answers
self-encoded QR barcode?
I was wondering if it's possible to create a QR in some file format, say png, then encode the png in QR, such that the resulting QR is the same one you started with?

naught101
- 18,687
- 19
- 90
- 138
8
votes
1 answer
How can I use the Haskell timeout function (in System.Timeout) to halt runaway computations?
The timeout function in System.Timeout sometimes fails to halt an infinite computation.
For example,
timeout 1000 $ print $ length [0..]
returns Nothing as expected because the timeout interrupts the infinite computation. But
timeout 1000 $ print…

Peter Schachte
- 81
- 2
8
votes
2 answers
How can I add a user interrupt to an infinite loop?
I have a ruby script below which infinitely prints numbers from 1 onward. How can I make the script stop its infinite execution through an interrupt in the terminal like 'Ctrl+C' or key 'q'?
a = 0
while( a )
puts a
a += 1
# the code should…

boddhisattva
- 6,908
- 11
- 48
- 72
8
votes
2 answers
Type reduction infinite loop
My aim is to eliminate () from terms, like this:
(a, b) -> (a, b)
((), b) -> b
(a, ((), b)) -> (a, b)
...
And this is the code:
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module…

Philip Kamenarsky
- 2,757
- 2
- 24
- 30
8
votes
5 answers
If you import yourself in Python, why don't you get an infinite loop?
This question is a response to the following SO post:
How do I pickle an object?
In that thread, the OP accidentally imports his own module at the top of the same module. Why doesn't this cause an infinite loop?

froadie
- 79,995
- 75
- 166
- 235
8
votes
6 answers
How can I test potentially "browser-crashing" JavaScript?
I've been having a crack at some of the problems over at http://projecteuler.net/ with JavaScript. I've been using a simple html page and running my code in script tags so I can log my results in the browsers' console. When experimenting with loops…

Dr. Frankenstein
- 4,634
- 7
- 33
- 48
8
votes
1 answer
How can I protect my Meteor server from an infinite loop on the client?
I've run into a situation where an infinite loop on the client is crashing the Meteor server. The infinite loop is a bug that I will fix, and not the subject of this question. My concern is that a malicious user could create their own infinite…

colllin
- 9,442
- 9
- 49
- 65
8
votes
1 answer
Passing variable through URL with angular js
I am using angular to make an e-commerce, and I'm setting an infinite scroll to the products list page. Everything worked fine, but I want to use the URL to set the page, so the user can access an specific page through URL. how do I set a variable…

Daniel Ortiz
- 901
- 2
- 7
- 14
8
votes
3 answers
How can I represent a file system's symbolic links in a Perl hash?
On Server Fault, How to list symbolic link chains? (not my question) talks about listing all the symbolic links and following them. To make this doable, let's consider a single directory at first.
I want to write a short utility that does this. It…

Paul
- 26,170
- 12
- 85
- 119