开发者

C++: More and more complex bugs misleading the debugger [closed]

开发者 https://www.devze.com 2023-03-15 07:41 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its curr开发者_运维知识库ent for
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its curr开发者_运维知识库ent form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

It seems like the bugs in my project are evolving. While in the beginning time, causers of program crashes were easily to spot using the debugger (the line it points to after the program crashes), it's different now.

Many bugs cause the program to crash in completely arbitary places not even closely related to them.

  • How can I spot bugs "hiding" from the debugger in a better way?

(I use Visual Studio 2010)


Profile your code for memory corruption, memory overwrites and memory leaks.


Root cause analysis.

When you find an obvious bug, don't just fix the bug, fix the coding style that allowed it.


If you have any code using raw memory and pointers, replace it by memory allocated using std::vector and its iterators. It will compile to exactly the same speedy code in Release mode, but in Debug mode it will used checked iterators, which will catch some bugs as early as possible.


Use memory corruption checking utilities, like gflags or debug heap. "Floating" crushes almost always come from corrupted memory in C++ programs

0

精彩评论

暂无评论...
验证码 换一张
取 消