two work vignettes; or, debugging is fun!

1. I had a bug filed to me about a hang happening. It started happening after some code I submitted in September that seemed pretty unrelated – I added a flag to let some calls be made in a certain way that _could_ cause a hang, but I only made one call behave that way, and I was pretty darn sure that wasn’t happening in this particular example.

So I tried to debug what was happening with the hang, but I don’t have a lot of experience figuring such things out, so I asked someone over to help. It took a few hours and we didn’t learn too much except it did seem to be related to the flag I added.

After stepping away from the keyboard a bit, I did some thinking, and realized that the only thing that made any sense is that my flag must be set on the call that was happening right before the hang. I couldn’t see how that would have happened, but I had an outlandish and unlikely theory.

The next day, I was eager to check it out, and lo and behold the flag was being set! When my breakpoint got hit, I was giddy with happiness because I had reasoned out the problem. Although my outlandish theory was totally wrong (the real culprit was a 64-bit int being silently coerced to a 32-bit int…grrr), I was happy I had deduced what must be happening.

Lesson: I’m often eager to jump in and start debugging, but thinking about the problem (i.e. playing “What Do We Know?”) can be valuable too.

2. I was debugging a different problem, and I knew some part of a data structure was returning some sort of error code from a particular operation. Unfortunately, I was debugging a release build, and so I didn’t have an easy way of figuring out which one since there was very little debug information about local variables, etc.

So, I dropped down to disassembly (which never lies!) and stepped through one statement at a time. When I found that a particular call returned an error, I would “Set Next Statement” to before the assembly was setting up the call and then step into it. It took a little while, but I was comforted that I was guaranteed to find which part of the structure was returning the error.

Anyway, it was neat because I felt like I was totally in control of the executing code. Fun times!

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s