inessential by Brent Simmons

The awesome self-repairing crashing bug

Back during the 3.1 beta period, just after the launch of Leopard, I created a self-referential (sort-of), self-repairing crashing bug.

Here’s the scoop:

I needed to revise the crash log reporter for Leopard, since crashes are now stored one per file, rather than one file per app.

So I did, and tested it (I already had a crash log on disk), and it worked great. Cool. Release beta.


The crash-log-finder code crashed when there were no NetNewsWire crash logs on disk. Since Leopard was new, the odds of there being no crash logs yet was pretty good.

So it crashed for a bunch of people. (Yes, a crashing bug about reporting crashes.)

However—and I bet you’ve figured this out already—it was self-repairing because, once it crashed, then next time you launch NetNewsWire, it would find the newly-created crash log just fine. And all was well from that point.

(Of course I fixed it asap anyway.)

In the end it was a stupid bug, an uninitialized variable. Something like this:

Where f is the path the crash log...

NSString *f;
[find the crash log...]
if (f)
    [do something with the crash log...]

Obviously, NSString *f = nil; was the answer.

(Good thing I’m secure in my coding skills or I’d never admit to such a stupid mistake. Normally I’m a compulsive variable initializer. Feh.)