C ++应用程序在发布模式下崩溃 [英] C++ application crashes in release mode

查看:85
本文介绍了C ++应用程序在发布模式下崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在调试模式下可以正常工作.但是在释放模式下它会任意崩溃.崩溃点表明它们要么在malloc中崩溃,要么在free中崩溃.我需要更改任何项目设置还是需要做其他事情吗?
等待及时的响应.

谢谢,
Dipak

My application works fine in debug mode. But it crashes arbitrarily in release mode. Crash point shows that either they are crashing in malloc or free. Do I need to change any project settings or something else need to be done?
Awaiting prompt response.

Thanks,
Dipak

推荐答案

我不认为您必须更改设置.我要检查您的代码.
在释放模式下检查malloc或free语句.
I don,t Think that u have to change setting. i thing u have to check your code .
check malloc or free statement in release mode.


可能有几个原因导致程序无法在Release模式下工作,而在Debug模式下工作.根据我的经验,最常见的是您的应用程序可能依赖的错误版本的第三方库(例如,在发行版本中链接调试库).

但是,正如您所描述的,您的程序在执行某些内存管理任务时失败(释放内存).通常是这种情况,因为您的代码中存在一些错误的内存管理.它在调试"模式下工作的事实并不能真正证明您的代码没有错误,尤其是在处理分配和释放内存时.这是因为在调试模式下,内存分配不同.可以说Debug模式更宽容,因为分配了更多的内存,而实际需要的内存更大(用于调试目的).因此,如果尝试访问一些应该是非法的内存(因为未正确分配内存),则由于分配了额外的内存,它仍可以在调试模式下工作.

我建议您查看您的代码,看看是否存在错误分配(按逻辑).在您描述的情况下,我认为您的问题不太可能与Project/Compiler设置有关.

我也可以向您建议有关CP的这篇文章,可能对您有很大帮助:
调试发布模式问题 [生存发行版 [
There maybe several reasons why a program doesnt work in Release but Debug mode. Most common from my experience are wrong versions of third-party libraries your application may depend on (e.g. linking debug libraries in release builds).

But as you described, your program fails at some memory management task (freeing memory). This is often the case because of some false memory management in your code. The fact that it works in Debug mode doesn''t really prove that your code is error free, especially when dealing with allocating and freeing memory. This is because in Debug mode the memory is allocated differently. Lets say that the Debug mode is more forgiving because more memory is allocated then is actually needed (for debugging purpose). Therefore if you try to access some memory that should be illegal (because you didnt allocate it properly) it could still work in Debug mode because of the additionaly allocated memory.

I would suggest you to look at your code and see if there maybe false allocations (by logic). In your described case i think is very unlikely that your problem is related to Project/Compiler settings.

I can also suggest you this article on CP about this topic which may be of great help to you:
Debugging Release Mode Problems[^]

Also this one seems to be very helpfull:
Surviving the Release Version[^]


程序崩溃的原因1在释放模式而不是调试模式下,是由于使用了初始化变量.未初始化的变量在每种模式下可以具有非常不同的值,因此,当程序使用其中一种时,其行为将有所不同.而且请不要误解,如果您使用统一变量,那么程序在两种模式下的行为均不正确,可能不会因为调试而崩溃.

使用变量之前,请确保对其进行初始化.
The number 1 reason a program crashes in release mode but not debug mode is due to using an initialized variable. Uninitialized variables can have very different values in each mode so your program will behave differently when it used one of these. And make no mistake, if you use an unitialized variable your program *is* misbehaving in both modes, it just may not crash because of it in debug.

Make sure you initialize any variable before you use it.


这篇关于C ++应用程序在发布模式下崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆