Today I ran in to a bug where a simple piece of code to choose a random color for an object went in to an infinite loop after running for more than 5 months normally.
To do this, it had to have x, where x is a number with greater than 20 decimal places and derived from the hash of the name of an object, meet these criteria.
( x % 255 ) % 3 == 0
( x % / 4 % 255 ) % 11 == 0
( x % / 5 % 255 ) % 7 == 0
In the last 5 months of the server running, it has never met that criteria, however one string which was input today resolved to a number which met all of them, resulting in the RGB color always equaling 0 and never growing to a number which was allowable (Non-black).
Therefore, the rule of Whiles: Always guarantee that your code will complete in a while loop in a finite number of loops.
Implementation for this instance: Guarantee on every loop that the code increments by at least 1 towards its goal and can never regress, allowing a simple proof that it will succeed in finite time.