Live data from Hacker News

Debugging: Indispensable rules for finding even the most elusive problems (2004)

dwheeler.com

31–40 of 238 posts

Re: Debugging: Indispensable rules for finding even the most elusive problems (2004)

#31
post #21

Step 10, add the bug as a test to the CI to prevent regressions? Make sure the CI fails before the fix and works after the fix.

What do you do with the years old bug fixes? How fast can one run the CI after a long while of accumulating tests? Do they still make sense to be kept in the long run?

I think for some types of bugs a CI test would be valuable if the developer believes regressions may occur, for other bugs they would be useless.

Re: Debugging: Indispensable rules for finding even the most elusive problems (2004)

#32
I’m so bad at #1.

I know it is the best route, I do know the system (maybe I wrote it) and yet time and again I don’t take the time to read what I should… and I make assumptions in hopes of speeding up the process/ fix, and I cost myself time…

Re: Debugging: Indispensable rules for finding even the most elusive problems (2004)

#33
For #4 (divide and conquer), I've found `git bisect` helps a lot. If you have a known good commit and one of dozens or hundreds of commits after that is bad, this can help you identify the bad commit / code in a few steps.

Here's a walk through on using it: https://nickjanetakis.com/blog/using-git-bisect-to-help-find...

I jumped into a pretty big unknown code base in a live consulting call and we found the problem pretty quickly using this method. Without that, the scope of where things could be broken was too big given the context (unfamiliar code base, multiple people working on it, only able to chat with 1 developer on the project, etc.).

Re: Debugging: Indispensable rules for finding even the most elusive problems (2004)

#36
Some additional rules: - "It is your own fault". Always suspect your code changes before anything else. It can be a compiler bug or even a hardware error, but those are very rare. - "When you find a bug, go back hunt down its family and friends". Think where else the same kind of thing could have happened, and check those. - "Optimize for the user first, the maintenance programmer second, and last if at all for the computer".

Re: Debugging: Indispensable rules for finding even the most elusive problems (2004)

#37
post #14

Make sure you're editing the correct file on the correct machine.

Yep, this is a variation of "check the plug"

I find myself doing this all the time now I will temporarily add a line to cause a fatal error, to check that it's the right file (and, depending on the situation, also the right line)

Re: Debugging: Indispensable rules for finding even the most elusive problems (2004)

#38

Step 10, add the bug as a test to the CI to prevent regressions? Make sure the CI fails before the fix and works after the fix.

Yes, just more generally document it

I've lost count of how many things i've fixed only to to see;

1) It recurs because a deeper "cause" of the bug reactivated it.

2) Nobody knew I fixed something so everyone continued to operate workarounds as if the bug was still there.

I realise these are related and arguably already fall under "You didn't fix it". That said a bit of writing-up and root-cause analysis after getting to "It's fixed!" seems helpful to others.

Post reply on HN