如果调试运行良好,但发布崩溃怎么办

2022-01-12 00:00:00 debugging release crash c++

我有一个在调试版本中运行良好的应用程序,但是当我在发布版本中启动它时,我得到了一个

I have an application that runs just fine in the debug build, but when I start it in the release build, I get a

unhandled Exception at 0x0043b134 in myapp.exe: 0xC0000005:
Access violation while reading at position 0x004bd96c

如果我点击break",它会告诉我没有加载任何符号并且无法显示源代码.

If I click on 'break' it tells me that there are no symbols loaded and the source code can't be displayed.

在这种情况下我可以做些什么来追查问题?

What can I do in such a situation to track down the problem?

推荐答案

这类问题往往是由于单元化变量造成的.我会从那里开始寻找你的问题.

This kind of problem is often due to unitialized variables. I'd start there looking for your problem.

调试模式更宽容,因为它通常被配置为初始化尚未显式初始化的变量.

Debug mode is more forgiving because it is often configured to initialize variables that have not been explicitly initialized.

也许您正在删除一个未初始化的指针.在调试模式下它可以工作,因为指针被清空并且删除 ptr 将在 NULL 上正常.发布时有点垃圾,然后删除ptr实际上会导致问题.

Perhaps you're deleting an unitialized pointer. In debug mode it works because pointer was nulled and delete ptr will be ok on NULL. On release it's some rubbish, then delete ptr will actually cause a problem.

相关文章