Mirror

| | Comments (1)
Every now and again something seems to hold up a mirror to you, and you get a brief glimpse of how you tend to come across to other people.

Case in point:

In code, there's something called a Mutex. If the program you're writing has several things going on, (anal probe sending images, something is saving images, the user is doodling mustaches on the images, etc.), you need some way to make sure that only one of them is using the image at a time. Well, you can use a Mutex (which is short for "Mutual Exclusion") to do that. It's kind of like the pig skull in Lord of the Flies.

Thus, you write in this line right before you start poking around with the image that says "Wait here until the Mutex is free". When that line is finished, magically, you have the mutex, and you're free to prod the image in safety. Then, when you're done, you release the mutex, and mutex manager will give the mutex to some other bit of code that's waiting for the mutex.

There are hundreds of ways to screw up Mutexes, but the most common way is to forget to release the freakin' mutex. So you have these five other parts of the program sitting there, waiting for the mutex which it'll never get.

The way to debug that, well, there are many ways to do it. The way I do it is with some kind of log file. So you let all the program run, with each bit of code making a note in the log when it has grabbed the mutex and when it's released it. Then, when the inevitable lockup happens, you dig through the log and figure out who screwed up and forgot to release the mutex.

So, I had this sort of issue about three or four months ago, and I threw a bunch of log statements into the big program-wide log file, fixed the issue, and then forgot about it. What I apparently didn't do was get rid of the log statements.

Fast forward to today. I was glancing at the log file, and noticed this line:

MAIN FORM: Now I have the Mutex! All shall bow before me!
My first thought was, "Man, who was the dork who wrote that line? Sheesh! What a bunch of melvins I work with."

Then I remembered it was me. That I'm that melvin I work with.

Now, at the time I wrote that, I was certainly burned out on debugging that issue, and I was probably also a bit sleep deprived. While that might explain why I wrote that line, it doesn't excuse it. Because you can't excuse the inexcusable.

Sometimes I'll read something I wrote and thing, "You know, that was really good." This isn't one of those times.

1 Comments

scott said:

That's not nearly as bad as what this guy I used to work with did.

He received a reprimand for including a comment in the source code along the lines of, "You know what they say about assumptions being the mother of all fuck ups."

What a melvin. haha.

Leave a comment

About this Entry

This page contains a single entry by Famous J published on January 19, 2006 6:07 PM.

Meat: Not as Cruel as You Think was the previous entry in this blog.

The Ricky Gervais Show is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.0