3 ms·
Not worst, but certainly embarrassing. A good many years ago, I was working for a small company, and we got to the stage where we could invest in a couple of hi
by mootothemax 16y ago
Not worst, but certainly embarrassing. A good many years ago, I was working for a small company, and we got to the stage where we could invest in a couple of high-end servers. I set everything up, started to test and couldn't log in to the web front-end: the new server was crashing as soon as I entered my login credentials. My non-technical boss was starting to get a bit confused about why we'd spent all of that money...
The login screen required 3 numbers from the user's PIN to be entered, being selected at random. So, pick a number at random between 1 and 10 (maximum PIN size), then pick another random number which hasn't already been generated, and do the same for the third number.
Problem: the random number generator object was created afresh for each number. The default seed value for the generator was the current time, but with no greater precision than seconds. Alarm bells started to ring.
The old server was so slow that the loop could run over several seconds - so getting a fresh random pseudorandom number each time. The new server had no such problems running our code, and IIS noticed an infinite loop and killed the thread before it had a chance to affect the rest of the server.
30 seconds after realising this, I moved the object creation out of the loop, and life was good again. Whoops.