It appears that some programmers think that Windows already ships with that time machine the Research division is working on

Raymond Chen

There are some compatibility bugs we investigate where the root cause is that the application relied on time travel. Wait, let me explain.

An application might issue an asynchronous request for a file to be renamed before they create the file itself. The program happened to work because it took time for the request to get scheduled and reach the file system, and that delay gave the application time to put the file on the disk just in time for the rename operation to see it.

Another example is an application which installs a shortcut onto the Start menu that points to a file that they haven’t installed yet. The installer happened to work because it took time for the Start menu to notice that a new shortcut was created, and by the time it went looking at the shortcut, the installer had copied the target into place.

Okay, so maybe it’s not so much a time machine as a race condition, but the inherent problem is that the application wanted to do some operation that was dependent on a prerequisite, but issued the operations in the wrong order, and they were relying on the fact that they could get the prerequisite done before the operation even noticed the problem.

It’s like writing a check with insufficient funds,¹ hoping that you can deposit money into the account before the check is cashed. If the check-cashing process ever gets optimized (say, by using electronic check presentation), your sneaky trick will stop working and your check will bounce.

Now, the developer of the application probably wasn’t consciously relying on this race condition, but they never noticed the problem during internal testing because they managed always to win the race. (Or maybe they did notice the problem during internal testing, but since it was sporadic, they chalked it up to “unreproducible failures”.)

In the case of the file renaming operation, losing the race condition means that the original file hangs around on the disk without being renamed. In the case of the shortcut, it means that your shortcut appears on the Start menu with a blank icon.

If you have one operation that relies upon the successful completion of a previous operation, it would be in your best interest to wait for the previous operation to complete before issuing the dependent operation.

¹ As technologically advanced as the United States purports to be, it is still quite common that payments between parties are made by sending little pieces of paper back and forth. For those who live in genuinely technologically advanced countries to whom the idea of sending pieces of paper is rather quaint, here’s how it works in the United States.

The original model for checks is simple.

  • Alice has an account at Alligator Bank and wishes to send $10 to Bob.
  • Alice writes a check, which is a piece of paper that says roughly “I authorize Alligator Bank to pay $10 from my account to Bob.”
  • Alice sends the check to Bob.
  • Bob goes to Alligator Bank and presents the check, along with proof that he is Bob.
  • Alligator Bank confirms the check’s validity, deducts $10 from Alice’s account, and gives Bob $10. (If this step fails, the check is said to have bounced.)
  • Alligator Bank stamps paid on the check and gives it back to Alice as confirmation that the payment occurred.

It’s inconvenient for Bob to have to go to Alligator Bank to get his money, but he can ask his bank to do it for him.

  • Bob has an account at Bunny Bank.
  • Bob goes to Bunny Bank and presents the check, along with proof that he is Bob.
  • Bunny Bank sends the check to Alligator Bank demanding payment.
  • Alligator Bank confirms the check’s validity, deducts $10 from Alice’s account, and sends $10 to Bunny Bank.
  • Bunny Bank credits $10 to Bob’s account.

Over the decades, there have been tweaks to the above process, but the basic system remains in place.

  • Instead of an O() algorithm (where each bank contacts each other bank), the system uses an O(n) algorithm (where each bank contacts a central clearinghouse, which then redistributes the checks).
  • Bunny Bank credits Bob’s account before receiving confirmation from Alligator Bank that the check is valid.
  • Check images are sent between banks instead of physical checks.

There is a category of scams that take advantage of the second detail. I’ll leave you to read about them yourself.

Electronic presentation is an alternative process wherein the information on the check is used to create an electronic payment, which is processed almost immediately, and the original check is never processed as a check.

0 comments

Discussion is closed.

Feedback usabilla icon