From the depths of time: a 30-year-old bug with a funny explanation

It was 1990 or possibly 1991, and I was working for System Simulation on an Application for Windows 2 – which at that time was a rather exotic extra that a few adventurous people were running on top of their MS-DOS systems. There was no graphical development environment in those days: you’d compile your program using the command-line C compiler cl, and compile your resources (dialogue boxes, menus and suchlike) using the command-line resource compiler, rc.

Although this was a bit laborious, it did work, and I was able to make some progress working on and off on this project through June and July. Then the first time I tried to rebuild the resources in August, the compiler rejected my files with a spectacularly uninformative error message: “bad octal digit”. It gave no indication of where in the file the problem was.

Anyone have an idea what was happening yet?

Next hint: we were using SCCS (“Source Code Control System”), an early and primitive version-control system that was the forerunner of tools like CVS and git. Now can you guess what was happening?

OK, last hint: I would have run into this problem before August if I’d been working full-time on the Windows project, rather than switching between this and other work. Specifically, the problem would have manifested in both June and July, but only on the 8th and 9th of the month.

Got it now?

It was a bug in the resource compiler. For some reason, its lexical analyser worked its way through comments, identifying and discarding lexical tokens within the comments rather than just identifying and discarding the entire comment. We were using a header-comment that contained the magic sequence %D%, which SCCS expands into the current date – this is nice because it means the first line of your file includes a note of when it was modified (and by whom, and what the file is called, depending on what other magic sequences you include).

The date was being rendered with the month in zero-padded form – so when I checked the file in on the first of August and tried to compile it, the header said something like:

/* st.rc, version 1.23, last modified 01/08/1990 */

And the resource compiler, seeing the sequence “08” in the middle of that comment, decided that the leading zero meant an octal integer constant, and then rejected it because 8 is not a valid octal digit.

Har har. How we laughed.

Lessons for today? Although the specific tool that did this is long gone, the obvious moral is that whatever else your development tools do, they should emit clear, specific error messages. It’s bad enough that rc lexed its way through my comment, but if had at least had the decency to say “bad octal constant ‘08’ at st.rc, line 1” then I wouldn’t have had to waste half a day scratching my head.


[Note: this post is modified from one that I posted in 2009 on my employer’s blog, but in contravention of basic Web etiquette, it’s vanished in a subsequent revamp of the site. The WayBack Machine has it but I don’t want to rely on that.]

4 responses to “From the depths of time: a 30-year-old bug with a funny explanation

  1. Dr C D Wright

    I had a similar issue with a customer who had 0-padded their IP addresses in the text file to get them all nicely lined up and formatted neatly, so I guessed your problem *very* quickly.

    Nice example, though.

  2. Using leading 0 to denote octal notation what a terrible idea that undoubtedly caused millions of bugs over the decades.

    Was C the originator of that particular bad idea? I wouldn’t be surprised. But to *really* stuff things you can rely on JavaScript, as usual. Evaluate the following in a browser console for a good laugh:

    [01, 02, 03, 04, 05, 06, 07, 08, 09, 010, 011, 012, 013, 014, 015, 016, 017, 018, 019]

  3. Congratulations, C D Wright!

    Pedro, that JavaScript example is absolute solid gold. (BTW., I assume you are familiar with Wat?)

  4. Yes indeed. Javascript is a never ending source of WAT moments.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.