<s>
In	O
computer	B-General_Concept
programming	I-General_Concept
,	O
an	O
infinite	B-Algorithm
loop	I-Algorithm
(	O
or	O
endless	B-Algorithm
loop	I-Algorithm
)	O
is	O
a	O
sequence	O
of	O
instructions	O
that	O
,	O
as	O
written	O
,	O
will	O
continue	O
endlessly	O
,	O
unless	O
an	O
external	O
intervention	O
occurs	O
(	O
"	O
pull	O
the	O
plug	O
"	O
)	O
.	O
</s>
<s>
This	O
differs	O
from	O
"	O
a	O
type	O
of	O
computer	B-Application
program	I-Application
that	O
runs	O
the	O
same	O
instructions	O
continuously	O
until	O
it	O
is	O
either	O
stopped	O
or	O
interrupted	O
"	O
.	O
</s>
<s>
Consider	O
the	O
following	O
pseudocode	B-Language
:	O
</s>
<s>
An	O
infinite	B-Algorithm
loop	I-Algorithm
is	O
a	O
sequence	O
of	O
instructions	O
in	O
a	O
computer	B-Application
program	I-Application
which	O
loops	O
endlessly	O
,	O
either	O
due	O
to	O
the	O
loop	O
having	O
no	O
terminating	B-Application
condition	O
,	O
having	O
one	O
that	O
can	O
never	O
be	O
met	O
,	O
or	O
one	O
that	O
causes	O
the	O
loop	O
to	O
start	O
over	O
.	O
</s>
<s>
In	O
older	O
operating	B-General_Concept
systems	I-General_Concept
with	O
cooperative	B-Operating_System
multitasking	I-Operating_System
,	O
infinite	B-Algorithm
loops	I-Algorithm
normally	O
caused	O
the	O
entire	O
system	O
to	O
become	O
unresponsive	O
.	O
</s>
<s>
With	O
the	O
now-prevalent	O
preemptive	O
multitasking	O
model	O
,	O
infinite	B-Algorithm
loops	I-Algorithm
usually	O
cause	O
the	O
program	O
to	O
consume	O
all	O
available	O
processor	O
time	O
,	O
but	O
can	O
usually	O
be	O
terminated	O
by	O
the	O
user	O
.	O
</s>
<s>
Busy	B-Operating_System
wait	I-Operating_System
loops	I-Operating_System
are	O
also	O
sometimes	O
called	O
"	O
infinite	B-Algorithm
loops	I-Algorithm
"	O
.	O
</s>
<s>
Infinite	B-Algorithm
loops	I-Algorithm
are	O
one	O
possible	O
cause	O
for	O
a	O
computer	O
"	O
freezing	B-General_Concept
"	O
;	O
others	O
include	O
thrashing	B-General_Concept
,	O
deadlock	B-Operating_System
,	O
and	O
access	B-Error_Name
violations	I-Error_Name
.	O
</s>
<s>
An	O
infinite	B-Algorithm
loop	I-Algorithm
occurs	O
when	O
the	O
condition	O
will	O
never	O
be	O
met	O
,	O
due	O
to	O
some	O
inherent	O
characteristic	O
of	O
the	O
loop	O
.	O
</s>
<s>
For	O
example	O
,	O
the	O
games	O
on	O
cartridge-based	O
game	O
consoles	O
typically	O
have	O
no	O
exit	O
condition	O
in	O
their	O
main	O
loop	O
,	O
as	O
there	O
is	O
no	O
operating	B-General_Concept
system	I-General_Concept
for	O
the	O
program	O
to	O
exit	O
to	O
;	O
the	O
loop	O
runs	O
until	O
the	O
console	O
is	O
powered	O
off	O
.	O
</s>
<s>
Modern	O
interactive	O
computers	O
require	O
that	O
the	O
computer	O
constantly	O
be	O
monitoring	O
for	O
user	O
input	O
or	O
device	O
activity	O
,	O
so	O
at	O
some	O
fundamental	O
level	O
there	O
is	O
an	O
infinite	O
processing	O
idle	B-Algorithm
loop	I-Algorithm
that	O
must	O
continue	O
until	O
the	O
device	O
is	O
turned	O
off	O
or	O
reset	O
.	O
</s>
<s>
In	O
the	O
Apollo	B-Application
Guidance	I-Application
Computer	I-Application
,	O
for	O
example	O
,	O
this	O
outer	O
loop	O
was	O
contained	O
in	O
the	O
Exec	O
program	O
,	O
and	O
if	O
the	O
computer	O
had	O
absolutely	O
no	O
other	O
work	O
to	O
do	O
it	O
would	O
loop	O
run	O
a	O
dummy	O
job	O
that	O
would	O
simply	O
turn	O
off	O
the	O
"	O
computer	O
activity	O
"	O
indicator	O
light	O
.	O
</s>
<s>
Instead	O
they	O
fall	O
back	O
to	O
an	O
error	O
condition	O
displaying	O
messages	O
to	O
the	O
operator	O
,	O
and	O
enter	O
an	O
infinite	B-Algorithm
loop	I-Algorithm
waiting	O
for	O
the	O
user	O
to	O
either	O
respond	O
to	O
a	O
prompt	O
to	O
continue	O
,	O
or	O
to	O
reset	O
the	O
device	O
.	O
</s>
<s>
In	O
multi-threaded	O
programs	O
some	O
threads	O
can	O
be	O
executing	O
inside	O
infinite	B-Algorithm
loops	I-Algorithm
without	O
causing	O
the	O
entire	O
program	O
to	O
be	O
stuck	O
in	O
an	O
infinite	B-Algorithm
loop	I-Algorithm
.	O
</s>
<s>
The	O
threads	O
inside	O
the	O
infinite	B-Algorithm
loops	I-Algorithm
can	O
perform	O
"	O
housekeeping	O
"	O
tasks	O
or	O
they	O
can	O
be	O
in	O
a	O
blocked	O
state	O
waiting	O
for	O
input	O
(	O
from	O
socket/queue	O
)	O
and	O
resume	O
execution	O
every	O
time	O
input	O
is	O
received	O
.	O
</s>
<s>
Most	O
often	O
,	O
the	O
term	O
is	O
used	O
for	O
those	O
situations	O
when	O
this	O
is	O
not	O
the	O
intended	O
result	O
;	O
that	O
is	O
,	O
when	O
this	O
is	O
a	O
bug	B-Error_Name
.	O
</s>
<s>
One	O
common	O
cause	O
,	O
for	O
example	O
,	O
is	O
that	O
the	O
programmer	O
intends	O
to	O
iterate	O
over	O
sequence	O
of	O
nodes	O
in	O
a	O
data	B-General_Concept
structure	I-General_Concept
such	O
as	O
a	O
linked	B-Data_Structure
list	I-Data_Structure
or	O
tree	B-Application
,	O
executing	O
the	O
loop	O
code	O
once	O
for	O
each	O
node	O
.	O
</s>
<s>
Improperly	O
formed	O
links	O
can	O
create	O
a	O
reference	O
loop	O
in	O
the	O
data	B-General_Concept
structure	I-General_Concept
,	O
where	O
one	O
node	O
links	O
to	O
another	O
that	O
occurs	O
earlier	O
in	O
the	O
sequence	O
.	O
</s>
<s>
This	O
makes	O
part	O
of	O
the	O
data	B-General_Concept
structure	I-General_Concept
into	O
a	O
ring	B-Data_Structure
,	O
causing	O
naive	O
code	O
to	O
loop	O
forever	O
.	O
</s>
<s>
While	O
most	O
infinite	B-Algorithm
loops	I-Algorithm
can	O
be	O
found	O
by	O
close	O
inspection	O
of	O
the	O
code	O
,	O
there	O
is	O
no	O
general	O
method	O
to	O
determine	O
whether	O
a	O
given	O
program	O
will	O
ever	O
halt	O
or	O
will	O
run	O
forever	O
;	O
this	O
is	O
the	O
undecidability	O
of	O
the	O
halting	O
problem	O
.	O
</s>
<s>
As	O
long	O
as	O
the	O
system	O
is	O
responsive	O
,	O
infinite	B-Algorithm
loops	I-Algorithm
can	O
often	O
be	O
interrupted	O
by	O
sending	O
a	O
signal	O
to	O
the	O
process	O
(	O
such	O
as	O
SIGINT	B-General_Concept
in	O
Unix	O
)	O
,	O
or	O
an	O
interrupt	B-Application
to	O
the	O
processor	O
,	O
causing	O
the	O
current	O
process	O
to	O
be	O
aborted	O
.	O
</s>
<s>
This	O
can	O
be	O
done	O
in	O
a	O
task	B-General_Concept
manager	I-General_Concept
,	O
in	O
a	O
terminal	O
with	O
the	O
Control-C	B-Device
command	O
,	O
or	O
by	O
using	O
the	O
kill	B-Operating_System
command	I-Operating_System
or	O
system	B-Operating_System
call	I-Operating_System
.	O
</s>
<s>
However	O
,	O
this	O
does	O
not	O
always	O
work	O
,	O
as	O
the	O
process	O
may	O
not	O
be	O
responding	O
to	O
signals	O
or	O
the	O
processor	O
may	O
be	O
in	O
an	O
uninterruptible	O
state	O
,	O
such	O
as	O
in	O
the	O
Cyrix	B-Error_Name
coma	I-Error_Name
bug	I-Error_Name
(	O
caused	O
by	O
overlapping	O
uninterruptible	O
instructions	O
in	O
an	O
instruction	B-General_Concept
pipeline	I-General_Concept
)	O
.	O
</s>
<s>
In	O
some	O
cases	O
other	O
signals	O
such	O
as	O
SIGKILL	B-General_Concept
can	O
work	O
,	O
as	O
they	O
do	O
not	O
require	O
the	O
process	O
to	O
be	O
responsive	O
,	O
while	O
in	O
other	O
cases	O
the	O
loop	O
cannot	O
be	O
terminated	O
short	O
of	O
system	O
shutdown	O
.	O
</s>
<s>
Infinite	B-Algorithm
loops	I-Algorithm
can	O
be	O
implemented	O
using	O
various	O
control	O
flow	O
constructs	O
.	O
</s>
<s>
Most	O
commonly	O
,	O
in	O
unstructured	O
programming	O
this	O
is	O
jump	O
back	O
up	O
(	O
goto	B-Application
)	O
,	O
while	O
in	O
structured	O
programming	O
this	O
is	O
an	O
indefinite	O
loop	O
(	O
while	O
loop	O
)	O
set	O
to	O
never	O
end	O
,	O
either	O
by	O
omitting	O
the	O
condition	O
or	O
explicitly	O
setting	O
it	O
to	O
true	O
,	O
as	O
while	O
(	O
true	O
)	O
....	O
</s>
<s>
Some	O
languages	O
have	O
special	O
constructs	O
for	O
infinite	B-Algorithm
loops	I-Algorithm
,	O
typically	O
by	O
omitting	O
the	O
condition	O
from	O
an	O
indefinite	O
loop	O
.	O
</s>
<s>
Examples	O
include	O
Ada	O
(	O
loop	O
...	O
end	O
loop	O
)	O
,	O
Fortran	O
(	O
DO	O
...	O
END	O
DO	O
)	O
,	O
Go	O
(	O
for	O
{	O
...	O
}	O
)	O
,	O
Ruby	O
(	O
loop	O
do	O
...	O
end	O
)	O
,	O
and	O
Rust	B-Application
(	O
loop	O
{	O
...	O
}	O
)	O
.	O
</s>
<s>
A	O
simple	O
example	O
(	O
in	O
C	B-Language
)	O
:	O
</s>
<s>
The	O
form	O
for	O
(;	O
;	O
)	O
for	O
an	O
infinite	B-Algorithm
loop	I-Algorithm
is	O
traditional	O
,	O
appearing	O
in	O
the	O
standard	O
reference	O
The	O
C	B-Language
Programming	I-Language
Language	I-Language
,	O
and	O
is	O
often	O
punningly	O
pronounced	O
"	O
forever	O
"	O
.	O
</s>
<s>
This	O
is	O
a	O
loop	O
that	O
will	O
print	O
"	O
Infinite	B-Algorithm
Loop	I-Algorithm
"	O
without	O
halting	O
.	O
</s>
<s>
A	O
similar	O
example	O
in	O
1980s-era	O
BASIC	B-Language
:	O
</s>
<s>
A	O
similar	O
example	O
in	O
DOS	B-Device
batch	O
files	O
:	O
</s>
<s>
Here	O
is	O
one	O
example	O
of	O
an	O
infinite	B-Algorithm
loop	I-Algorithm
in	O
Visual	B-Language
Basic	I-Language
:	O
</s>
<s>
Essentially	O
what	O
this	O
infinite	B-Algorithm
loop	I-Algorithm
does	O
is	O
to	O
instruct	O
a	O
computer	O
to	O
keep	O
on	O
adding	O
1	O
to	O
1	O
until	O
5	O
is	O
reached	O
.	O
</s>
<s>
In	O
some	O
languages	O
,	O
programmer	O
confusion	O
about	O
the	O
mathematical	O
symbols	O
may	O
lead	O
to	O
an	O
unintentional	O
infinite	B-Algorithm
loop	I-Algorithm
.	O
</s>
<s>
For	O
example	O
,	O
here	O
is	O
a	O
snippet	O
in	O
C	B-Language
:	O
</s>
<s>
C	B-Language
output	O
on	O
an	O
AMD	O
Turion	O
processor:x	O
=	O
0.10000000149011611938	O
x	O
=	O
0.20000000298023223877	O
x	O
=	O
0.30000001192092895508	O
x	O
=	O
0.40000000596046447754	O
x	O
=	O
0.50000000000000000000	O
x	O
=	O
0.60000002384185791016	O
x	O
=	O
0.70000004768371582031	O
x	O
=	O
0.80000007152557373047	O
x	O
=	O
0.90000009536743164062	O
x	O
=	O
1.00000011920928955078	O
x	O
=	O
1.10000014305114746094	O
x	O
=	O
1.20000016689300537109	O
...	O
</s>
<s>
Unexpected	O
behavior	O
in	O
evaluating	O
the	O
terminating	B-Application
condition	O
can	O
also	O
cause	O
this	O
problem	O
.	O
</s>
<s>
Here	O
is	O
an	O
example	O
in	O
C	B-Language
:	O
</s>
<s>
The	O
problem	O
is	O
that	O
the	O
loop	O
terminating	B-Application
condition	O
(	O
x	O
!=	O
1.1	O
)	O
tests	O
for	O
exact	O
equality	O
of	O
two	O
floating	B-Algorithm
point	I-Algorithm
values	I-Algorithm
,	O
and	O
the	O
way	O
floating	B-Algorithm
point	I-Algorithm
values	I-Algorithm
are	O
represented	O
in	O
many	O
computers	O
will	O
make	O
this	O
test	O
fail	O
,	O
because	O
they	O
cannot	O
represent	O
the	O
value	O
0.1	O
exactly	O
,	O
thus	O
introducing	O
rounding	O
errors	O
on	O
each	O
increment	O
(	O
cf	O
.	O
</s>
<s>
The	O
same	O
can	O
happen	O
in	O
Python	B-Language
:	O
</s>
<s>
Because	O
of	O
the	O
likelihood	O
of	O
tests	O
for	O
equality	O
or	O
not-equality	O
failing	O
unexpectedly	O
,	O
it	O
is	O
safer	O
to	O
use	O
greater-than	O
or	O
less-than	O
tests	O
when	O
dealing	O
with	O
floating-point	B-Algorithm
values	O
.	O
</s>
<s>
A	O
similar	O
problem	O
occurs	O
frequently	O
in	O
numerical	B-General_Concept
analysis	I-General_Concept
:	O
in	O
order	O
to	O
compute	O
a	O
certain	O
result	O
,	O
an	O
iteration	O
is	O
intended	O
to	O
be	O
carried	O
out	O
until	O
the	O
error	O
is	O
smaller	O
than	O
a	O
chosen	O
tolerance	O
.	O
</s>
<s>
However	O
,	O
because	O
of	O
rounding	O
errors	O
during	O
the	O
iteration	O
,	O
the	O
specified	O
tolerance	O
can	O
never	O
be	O
reached	O
,	O
resulting	O
in	O
an	O
infinite	B-Algorithm
loop	I-Algorithm
.	O
</s>
<s>
An	O
infinite	B-Algorithm
loop	I-Algorithm
may	O
be	O
caused	O
by	O
several	O
entities	O
interacting	O
.	O
</s>
<s>
Even	O
if	O
there	O
is	O
no	O
possibility	O
for	O
an	O
infinite	B-Algorithm
loop	I-Algorithm
within	O
the	O
server	O
itself	O
,	O
a	O
system	O
comprising	O
two	O
of	O
them	O
(	O
A	O
and	O
B	O
)	O
may	O
loop	O
endlessly	O
:	O
if	O
A	O
receives	O
a	O
message	O
of	O
unknown	O
type	O
from	O
B	O
,	O
then	O
A	O
replies	O
with	O
an	O
error	O
message	O
to	O
B	O
;	O
if	O
B	O
does	O
not	O
understand	O
the	O
error	O
message	O
,	O
it	O
replies	O
to	O
A	O
with	O
its	O
own	O
error	O
message	O
;	O
if	O
A	O
does	O
not	O
understand	O
the	O
error	O
message	O
from	O
B	O
,	O
it	O
sends	O
yet	O
another	O
error	O
message	O
,	O
and	O
so	O
on	O
.	O
</s>
<s>
An	O
example	O
in	O
bash	B-Operating_System
:	O
</s>
<s>
An	O
example	O
for	B-Language
loop	I-Language
in	O
C	B-Language
:	O
</s>
<s>
The	O
actual	O
limit	O
of	O
i	O
depends	O
on	O
the	O
details	O
of	O
the	O
system	O
and	O
compiler	B-Language
used	O
.	O
</s>
<s>
With	O
arbitrary-precision	B-Algorithm
arithmetic	I-Algorithm
,	O
this	O
loop	O
would	O
continue	O
until	O
the	O
computer	O
's	O
memory	B-General_Concept
could	O
no	O
longer	O
hold	O
i	O
.	O
</s>
<s>
In	O
this	O
case	O
,	O
the	O
compiler	B-Language
could	O
optimize	O
the	O
code	O
into	O
an	O
infinite	B-Algorithm
loop	I-Algorithm
.	O
</s>
<s>
Infinite	O
recursion	O
is	O
a	O
special	O
case	O
of	O
an	O
infinite	B-Algorithm
loop	I-Algorithm
that	O
is	O
caused	O
by	O
recursion	O
.	O
</s>
<s>
The	O
following	O
example	O
in	O
VBA	B-Language
returns	O
a	O
stack	B-Error_Name
overflow	I-Error_Name
error	O
:	O
</s>
<s>
A	O
"	O
while	O
(	O
true	O
)	O
"	O
loop	O
looks	O
infinite	O
at	O
first	O
glance	O
,	O
but	O
there	O
may	O
be	O
a	O
way	O
to	O
escape	O
the	O
loop	O
through	O
a	O
break	O
statement	O
or	O
return	B-Language
statement	I-Language
.	O
</s>
<s>
Example	O
in	O
PHP	B-Application
:	O
</s>
<s>
Alderson	O
loop	O
is	O
a	O
rare	O
slang	O
or	O
jargon	O
term	O
for	O
an	O
infinite	B-Algorithm
loop	I-Algorithm
where	O
there	O
is	O
an	O
exit	O
condition	O
available	O
,	O
but	O
inaccessible	O
in	O
the	O
current	O
implementation	O
of	O
the	O
code	O
,	O
typically	O
due	O
to	O
a	O
programmer	O
's	O
error	O
.	O
</s>
<s>
These	O
are	O
most	O
common	O
and	O
visible	O
while	O
debugging	O
user	B-Application
interface	I-Application
code	O
.	O
</s>
<s>
A	O
C-like	O
pseudocode	B-Language
example	O
of	O
an	O
Alderson	O
loop	O
,	O
where	O
the	O
program	O
is	O
supposed	O
to	O
sum	O
numbers	O
given	O
by	O
the	O
user	O
until	O
zero	O
is	O
given	O
,	O
but	O
where	O
the	O
programmer	O
has	O
used	O
the	O
wrong	O
operator	O
:	O
</s>
<s>
The	O
term	O
allegedly	O
received	O
its	O
name	O
from	O
a	O
programmer	O
(	O
last	O
name	O
Alderson	O
)	O
who	O
in	O
1996	O
had	O
coded	O
a	O
modal	O
dialog	O
box	O
in	O
Microsoft	B-Application
Access	I-Application
without	O
either	O
an	O
OK	O
or	O
Cancel	O
button	O
,	O
thereby	O
disabling	O
the	O
entire	O
program	O
whenever	O
the	O
box	O
came	O
up	O
.	O
</s>
