Time to narrate yet another story of my trouble with C++ debugging (with GDB via Code::Blocks). That one seemed even more weird than the time where no debugging symbols were placed in the debug executable. At some point, given some specific input, the program crashed both in release and debug (with no breakpoint) mode… but when run step-by-step it would work properly… what the heck, really…
The crash terminated the program with 0xC0000005: Access Violation. So, memory issue. After asking here and there (offline, yay! :D), I was eventually told that memory is handled really quite differently when debugging step-by-step and when running normally (even a “debug” build). I did know that, but never thought the difference was big enough to prevent a memory violation crash: after all, if running step-by-step “fixes” such big issues “automatically”, then debugging is kind of broken… So, no way to debug using the debugger… I was left with only one option: reading the code again looking for something that would generate memory violation, and placing some std::cout to check my variables before the crash.
In my particular case, I dealt with quite a few arrays, passing their lengths all around the place and accessing indexes according to ranges defined by other variables which was supposed to match… but eventually didn’t. Long story short, in rare cases, I was reading and even writing out of some arrays’ limits. That can do a crash case not reproducible when running step-by-step.
Some sources that helped:
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.