Best practices and tools for debugging differences between Debug and Release builds?

后端 未结 6 1812
失恋的感觉
失恋的感觉 2021-02-14 00:40

I\'ve seen posts talk about what might cause differences between Debug and Release builds, but I don\'t think anybody has addressed from a development standpoint what is

6条回答
  •  时光取名叫无心
    2021-02-14 01:20

    The best solution is to set up something like automated unit testing to thoroughly test all aspects of the application (not just individual components, but real world tests which use the application the same way a regular user would with all of the dependencies). This allows you to know immediately when a release-only bug has been introduced which should give you a good idea of where the problem is.

    Good practice to actively monitor and seek out problems beats any tool to help you fix them long after they happen.

    However, when you have one of those cases where it's too late: too many builds have gone by, can't reproduce consistently, etc. then I don't know of any one tool for the job. Sometimes fiddling with your release settings can give a bit of insight as to why the bug is occurring: if you can eliminate optimizations which suddenly make the bug go away, that could give you some useful information about it.

    Release-only bugs can fall into various categories, but the most common ones (aside from something like a misuse of assertions) is:

    1) Uninitialized memory. I use this term over uninitialized variables as a variable may be initialized but still be pointing to memory which hasn't been initialized properly. For this, memory diagnostic tools like Valgrind can help.

    2) Timing (ex: race conditions). These can be a nightmare to debug, but there are some multithreading profilers and diagnostic tools which can help. I can't suggest any off the bat, but there's Coverity Integrity Manager as one example.

提交回复
热议问题