How to Fix this Code

("How to Fix this Code" is set to the music of "How Far I'll Go", original music and lyrics by Lin-Manuel Miranda from the Disney film Moana. Alternate lyrics are by Steven Wolfman, Patrick Virtue, and Rachel Pottinger.)

I've been staring at this bug in my program
Long as I can remember, never really knowing why
I wish I had started with my test suite
But I thought I could be so l33t, and now it doesn't even compile

Every tweak I make, every pointless hack
Every point I break, every issue tracked
Leads me back again, to this exception4.5
That I cannot beat

Here's the line where the runtime tells me it's faulty
And I don't know how to fix this code
Trace the stack and go back to the lines I wrote blindly
Can I fix this code? If I show the local variables I might know.

I know every function in this program
has a role in this program
Everything is by design
I know every function in this program
meets its spec in this program
but the bugs are unspecified

I ran gdb. I can try valgrind.
There's no memory leak. None that I can find.
But I read this value that's undefined
That's assigned right here

Eerie Heisenbug hides when I seek—like it mind reads—
In threads transposed by my repros
And it seems like it's calling out to me so come find me!
Review this code:
What if these two lines had been synchronized

Here's the line where the runtime tells me it's faulty
I think I know how to fix this code
I just needed a monitor to keep these from fighting
Now I know
How to fix this code!

Footnotes

  1. It would be lovely if the first bug were the one caught by Rear Admiral Grace Murray Hopper, but it wasn't, as Hopper herself pointed out. In fact, Edison was already referring to bugs in 1878.[1]
  2. Test Suite /ˈtɛst swiːt/: The collection of tests that the mini-maxing programmer writes first to seriously raise their DEX.
  3. That is, 'leet', meaning elite and referring to a whole swath of linguistic and cultural baggage well above the weight limit of these footnotes. Briefly, let's just say that the narrative arc of the song can be described as the transition from pwnd to pwnzer, and 13@\/3 it at that.
  4. By which we mean pausing a program during debugging rather than combining surfing, Buddhism, skydiving, and law enforcement. Say.. breakpoints and the Police? "Every step you take, every point you break, I'll put a watch on you."
  5. The function call stack is a list of which function called which other function broken into categories by whose fault it is, in order from: "someone else on my team" through "an entirely natural oversight" to "the incompetent compiler's/framework's/library's".
  6. gdb (the GNU Project Debugger) is a debugging framework older than you. Well, not you, but certainly your students.
  7. valgrind is a memory leak checker and much more. It probably could have found the race condition that caused all the trouble in this song, if only the author had known about the entrance to Hel and not just Valhalla.
  8. A bug that appears and disappears from moment to moment with distressing velocity, if not both at the same time.
  9. Steps to repro:
    1. Open a web browser.
    2. Search for repro.
    3. Click the first link.
    4. Read until you find the definition.

    Expected results: You learn the definition of "repro".

    Actual Results: Somebody tries to sell you photographic services.

    Status changed from Active to Fixed.

    Comment: search for "bug repro" instead.

  10. By synchronized, we mean ensuring that one completes before the other starts or vice versa. By synchronized we mean ensuring that the two cannot both execute at the the same time.
  11. Semaphore scans quite nicely at this point in the song as well, but you should feel free to take a deep breath and smoosh in "condition variable" or "critical section" or whatever. You know what? You do you, recursively.

Return to Steve's Parody Lyrics Page
Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.