Skip to content

Comment on Software Folklore – A collection of weird bug storiesparent

Comments

One similar story: I was maintaining some C++ code that had a few #ifdefs in it. Someone reported a problem.

I put a breakpoint on the calling code and traced into my code. It went into the #ifdef code I expected, but the problem persisted.

Just to double-check, I let the program run until it hit the breakpoint again and traced in, but this time, it went into the #else code! That code should have been removed by the preprocessor, yet here I was, currenting stepping through it.

After questioning my understanding of the C preprocessor (and my own sanity), I luckily noticed that the module name in the debugger was very slightly different in the two cases mentioned above.

The world finally made sense again. My code was in a header file that was compiled (with different symbols defined) into two different modules and both of those modules were loaded into the same process. When I set the breakpoint in the debugger, it silently set breakpoints in both modules.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.