All software has bugs, but this one is a particularly odd one. If you type “File:///” (no quotes, the f must be capitalized) into almost any app on your Mac, it will crash. We’ve tested this hilarious curiosity here at TNW, so feel free to try it out yourself.

The discovery was made recently and a bug report was posted to Open Radar on Thursday. It only gained a lot of attention on Friday night though, thanks to a Hacker News submission.

First off, it’s worth noting that the bug only appears to be present in OS X Mountain Lion and is not reproducible in Lion or Snow Leopard. That’s not exactly good news given that this is the latest release of Apple’s operating system, which an increasing number of Mac users have switched to.

The most upvoted comment on HackerNews is from NelsonMinar, who points out that bug amusingly even crashes the Mac error reporter. Before it crashed though, he managed to copy and paste a crash dump, which you can check out on PasteBin.

The underlying reported error is as follows:

*** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘condition “wrong extraction: File:///”‘

terminate called throwing an exception

abort() called

A closer look shows the bug is inside Data Detectors, a feature that lets apps recognize dates, locations, and contact data, making it easy for you to save this information in your address book and calendar. HackerNews user 0x0 explains:

Looks like it triggers on anything starting with file:// (+/) case-insensitive, but then something later in the data extraction makes the incorrect assumption that the string should start with file:// (+/) lowercase, and throws an assert. It’s really quite bad that a bug inside the data detectors can bring down a whole app.

Nik Cubrilovic adds a bit more to solve the mystery:

checkDataDetectors will extract ‘File://a/’ – or any other ‘complete’ file URL – which at a minimum is a schema (file://) and a path ‘/’ – as a valid data URL and then pass it to DDResultCopyExtractURL, which does some additional sanity checking.

There it validates it by asserting that the URL begins with ‘file://’, which it doesn’t. It then converts to an NSInternalInconsistencyException which is what crashes the application, since it isn’t caught.

The timing differences that people are seeing is because the NSSpellCheckerCheckString process checks the spelling only after your key entry has been idle for a short period.

checkDataDetectors will also run if you simply open a file or application with this text inside it in a text control. When declaring your text control class you can disable the automated spell checking and data extraction (which will run even if you have spell checking disabled).

Finally, HackerNews user zbowling noted that many apps crashed for him but SublimeText did not. As commenters pointed out, this is because it doesn’t use NSTextFields, and therefore, doesn’t use Data Detectors. As such, only apps that have a NSTextField on Mountain Lion will crash.

Since the bug has been reported to Apple, it will likely be patched at some point. It’s not exactly a critical one though, so it may take a while. In the meantime, if you tested this out and your app is automatically crashing itself all the time, go to System Preferences, go to Language & Text, then Text, and uncheck “Correct spelling automatically” as well as “Use symbol and text substitution.”

This whole issue reminds me of a funny video from a couple years back:

Update on March 14: Apple fixed this issue in OS X 10.8.3.

Image credit: Moriel

Read next: The Redditlet bookmarklet brings the best of Reddit to the website you are current reading