Use the Surrender Tactic: Frustration when debugging
kedyr.wordpress.com
kedyr.wordpress.com
On the other hand if you spend a lot of time with no progress, then maybe you should stop and come back to it later, depending on priority, etc.
I may have made no progress towards the task in these 2 full days I spent working solving this issue, however I have greatly improved my CUDA programming knowledge and debugging technique, which I would have otherwise never done, so when I inevitably reach another bug It should (hopefully) be much quicker for me to solve.
- The bug doesn't reproduce when run under the debugger (not so uncommon with C code). Or the bug goes away when you change the timing of the code by writing to a log file.
- The bug could be in code that you didn't write and don't yet completely understand; the people who wrote the code have all left the company.
- The bug can be in a third-party library that you don't even have the source code to. You can only infer what the library is doing by seeing how it reacts to what you're passing it. Or you can try disassembling its code.
- The bug can be due to bad machine code generated by a compiler.
- The bug can be due to undocumented behavior in an operating system.
- The bug could be in a really complex algorithm.
- The bug might only reproduce at a customer's site with the customer's confidential data.
- The bug might be sporadic, perhaps depending on certain patterns of network traffic.
- The bug could be due to a fundamental misunderstanding of the original project requirements that will only become apparent after days of investigation.
back to the original post; i kind of like this in a mildly manner. as said in another comment, I also tend to hunt until I recognize a lockup. At that time I step back, walk to a drawing board and invite some colleagues to hear my brain pondering and running over several options while visualizing the pipeline on the board. This gives me three things: - experience of other colleagues - visualization of the problem to get clear what is happening. - probably coffee and some smalltalk over completely different things which at that time seem completely logical to originate from the thing explained. It relaxes me.
Back at my desk Im all fresh again, new ideas to try out etc. Bottom line, sometimes taking a step back helps for me as well. Although I like to see it as a last resort, while I (now again) know I should start doing this more often, and especially at an earlier stage.
To end with the start, when you run in a multiple day bug you should immediatly write a test for it, after solving. Make sure you dont run in it again :).
I finally found the issue, but only after close study of the code. I realized that one signal handlers was different than all the others, and that signal handler was calling some non-thread safe code. But because I wasn't using threads, the thought of a critical section of code being interrupted never occurred to me.
Now I spend my work time finding bugs in a distributed system. Fun times. (latest possible bug---one component stoped logging but only after what I would call "ludicrous load" (say, 1000+ load average)---it was still running, but apparently got wedged on a mutex)
This particular bug wasn't in my code but on the platform the code needed to run on. Because of my wrong approach to debugging I ended up spending more time looking in the wrong place for the bug. so actually what I thought was debugging was just time wasting.