Most common reasons for unstable bugs in C++?

后端 未结 9 1739
终归单人心
终归单人心 2020-12-28 23:16

I am currently working on a large project, and I spend most of the time debugging. While debugging is a normal process, there are bugs, that are unstable, and these bugs are

相关标签:
9条回答
  • 2020-12-28 23:53
    • buffer overflows
    • using pointers to deleted objects
    • returning invalid references or references to out of scope objects
    • unhandled exceptions
    • resource leaks (not only memory)
    • infinite recursion

    • dynamic libraries version mismatch

    0 讨论(0)
  • 2020-12-28 23:55

    Race conditions.

    These are one of the few things that still sends a shiver down my spine when it comes up in debugging (or in the issue tracker). Inherently horrible to debug, and extremely easy to create. The three most common causes of bugs in my C++ software have been race conditions, reliance on uninitialised memory, and reliance on static constructor order.

    And if you don't know what race conditions are, chances are they're the cause of your instability ;)

    0 讨论(0)
  • 2020-12-28 23:59

    If you are really in a position where you already have bad code that breaks, the best plan is probably to throw as many tools at it as you can (OS/lib-level memory checking, automated testing, logging, core dumps, etc) to find the problem areas. Then rewrite the code to do something more deterministic. Most of the bugs come from people doing things that mostly work most of the time, but C++ offers stronger guarantees if you use the right tools and approaches.

    0 讨论(0)
提交回复
热议问题