My Authors
Read all threads
I shipped a word processor that formatted the hard drive every 1024 saves.
Must have '84 or '85. I was a bright 25-year-old with about five years in the game. I was one of two programmers who wrote & maintained a suite of apps kinda like Office: spreadsheet, wp, database, plotter, such like. We customized everything for three or four vertical markets.
So I wrote most of the wp. This was in Forth, on a variety of OS/CPU combinations. Young'uns don't necessarily know this, but in those fays there'd be a new microcomputer with a custom OS and one of several CPU's every *month* or so.
Forth used block-based disk i/o. Each block was 1kb in length, and to save anything larger than 1kb, you ended up with a file master block that would contain offsets to the blocks that had the data, basically a pair of lists, allocated and none.
To initialize that file master, I'd fill it with zero's. And away we go!

Long story short, I changed the app to allow us to have files that were twice as long as we'd had previously, and the 256 entries in the file master became 1024.
Each entry was -- and here we go -- a *word* you see, of 16 bits. So, while growing that size to 512 would still fit in my 1k master block, growing it to 1024 would require two of those blocks.
So I changed the *fill* number, for those zeros, without changing the *buffer* size. In unprotected memory situations, when you fill 2048 zeros over 1024 bytes, the extra bytes overwrite, well, whatever random crap is in memory beyond that buffer size.
In my case, "whatever random crap" was the o/s's *master* *disk* *block*. Yes. When I went to initialze the new file, which happened every 1024 saves of a 1-block file, I overwrote the drive's master block, eliminating all of its files.
So, yeah, sure enough. We shipped that version of the code for, idunno, 8 or 9 weeks. And you can imagine the phone calls I was handling from the customers. We wound up telling everyone to always back up (to VCR tapes, btw) *every* *single* *day*.
I spent whole weeks doing nothing but making apologies by phone and running my app in the debugger over and over and over again. Nothing. I got nothing.
One woman called though, and she said she'd made her -- this was a trucking company, and this woman's use of profanity will serve me as a personal model for all the rest of my days -- had made her backup, fired up the wp, and *immediately* wiped her drive.
She'd reloaded the backup and it again *immediately* wiped her drive. She was seriously pissed.

Do you know it took me almost two hours to realize what I had? I was telling my s.o. the story at lunch, and then I was like, wait. Wait. *Immediately*? *Every* *time*.
I called her up and promised her everything, *everything*, if she would just pack that tape up and fedex it to me. I told her we'd pay the shipping and waive their monthly charges. (My boss never hesitated, he was like, "Oh *hell* yeah we'll waive the charges.")
I finally had the bug replicated. She wasn't lying. The forth image that had been backed up had the critical point: 1023 saves at the time the backup was done. Load the backup, do a save, get a wipe, guaranteed.
I may be exaggerating, but I'm pretty sure I found the problem the same morning the tape got delivered. It was that simple to see in the debugger.
I was looking at the 2k block about to be filled, and the last 1k was, idunno, *garbage*. That seemed odd, so I investigated it. Of course, it wasn't garbage, it was the 1024 bytes of the drive's master disk block, stashed next to my file master block by the operating system.
What I had was "pre" core dump. I didn't have the core dump, but I had a guaranteed route to the defect. If I hadn't gotten lucky, I'd've never found it. It had simply never occurred to me that I was writing to system memory instead of my own.
So, yeah. Your master geek shipped a word processor that, for eight or nine weeks, every 1024'th save, would format the customer's hard drive.

Cuz. You know. I got *skillz*.
There are prolly lots of morals to the story, but the two I'll highlight for any juniors:

1) Don't use numeric literals for anything but 0, 1, and -1.

2) Don't be so hard on yourself. *All* your old seniors have stories like this, and some of us have *several* of them.

Like my content? Cool. Most of my twitter threads become blogs and podcasts, and you can make sure you never miss one. It's free, it's spam-free, and it's supporting me.

Subscribe now!
Missing some Tweet in this thread? You can try to force a refresh.

Enjoying this thread?

Keep Current with GeePaw Hill

Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!

This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!