释放/调试地狱,与V-studio C ++项目 [英] Release /Debug hell, with V-studio C++ project

查看:252
本文介绍了释放/调试地狱,与V-studio C ++项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我厌倦了这种情况。我在使用C ++的Visual Studio工作,并在开发一个远在发展之前,在尝试发行版构建/运行周期,只是为了找到我的版本构建崩溃。它让我没有办法解决这个问题,除了破解大块的代码寻找所有潜在的违法者。无论如何,如果我进入我的发布项目属性,并启用调试数据库编辑并继续,甚至不启用链接器中的调试,发行版本完美运行。



好的,我真的很感激任何输入,什么样的事情寻找正确地获得我的版本的工作,但我敢问这个问题:谁关心?我理解,如果链接器事实上链接DEBUG版本的运行时和Windows库,程序可能不会运行在没有安装VStudio的任何系统上。但是我正在做什么...只是让编译器DEBUG格式设置为Program Database for Edit& Continue(/ ZI)。它几乎不会在应用程序的六个1K的差异,如果它不会停止EXE的工作,也许我应该离开它设置那样?

解决方案



< 谁在乎? ...嗯,你应该这样。



发布版本崩溃表明有错误。



如果打开调试符号修复它,那么你有一个魔法修复,你不明白。为什么它修复它?你可以依靠这个修复程序在你的软件安装在每台电脑上吗?



你描述的症状表明你正在损坏内存某处(缓冲区溢出错误最可能)并且添加调试符号会重新安排或填充你的代码,以便你可以摆脱它,因为内存损坏不会发生任何重要的命中。



但你不能真正依赖这样的修复。它会破坏您对应用程序的所有信心,并且会有一天会咬你(这样的修复可能会在下次编译应用程序时轻松停止工作)



你需要隔离是什么导致这个问题 - 如果它发生不止一次,那么你没有从上次修复它的任何东西。它不是正常的应用程序运行在调试,但不是在发布,所以必须有一些你做错了 - 你需要弄清楚它是什么,并修复它,以避免这样的错误在未来。 (例如,如果它是一个缓冲区溢出它可能只是你分配一个n元素的缓冲区,然后访问元素n - 你应该只访问元素0到(n-1)。这是很容易修复一次你理解如何编写这样的代码...但你必须付出一些努力,弄清楚你是做错了什么)


I'm so tired of this happening. I'm working in Visual studio using C++, and go a little to far in developemnt before attempting a release build/run cycle, only to find my release build crashes. It leaves me no way to fix the problem beyond to hack out big chunks of code looking for all potential violators. Anyway, If I go into my "release" project properties and enable the debug database for "Edit and Continue", and DON'T even enable Debugging in the linker, the Release version runs perfectly.

OK, I do appreciate any input as to what kinds of thing to look for to properly get my Release version to work, but dare I ask this question: "Who Cares"? I understand that if the linker does in fact link with DEBUG versions of runtime and windows libraries, that the program probably won't run on any system that doesn't have VStudio installed. But what about what I'm doing... just letting the compiler DEBUG format set to "Program Database for Edit & Continue (/ZI)". It hardly makes a 1K difference in the sixze of the application, and if it won't stop the EXE from working, maybe I should just leave it set that way? Or am I asking for trouble?

--Randy

解决方案

"Who cares?" ... well, you should.

The fact that the release build crashes indicates there is something wrong with it.

If turning on debug symbols "fixes" it, then you have a magic fix that you don't understand. Why does it fix it? Can you rely on this fix working on every PC your software is installed on?

The symptoms you describe suggest that you are corrupting memory somewhere (a buffer overrun error most likely) and that addition of debugging symbols rearranges or pads out your code in such a way that you can "get away with it" because the memory corruption doesn't happen to hit anything vital.

But you can't really rely on such a fix. It undermines all confidence in your application, and it will bite you one day (such a fix could easily stop "working" the next time you compile your app)

You need to isolate what it is that causes this problem - if it happens more than once then you haven't learned anything from the last time you fixed it. It's not "normal" for an application to run in debug but not in release, so there must be something you're doing wrong - you need to work out what it is and fix it so that you avoid such bugs in future. (e.g. If it's a buffer overrun it may simply be that you are allocating a buffer of "n" elements and then accessing element "n" - you should only access elements 0 to (n-1). THis is very easy to fix once you understand how to write such code... but you have to put in a bit of effort to work out what it is youre doing wrong)

这篇关于释放/调试地狱,与V-studio C ++项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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