简体   繁体   English

我的C ++应用程序仅在发布模式和Windows 7中崩溃

[英]My C++ App Crashes Only in Release Mode and Windows 7

I'm very frustrated with my app crash in Release Mode on Windows 7. 我对Windows 7上的发布模式中的应用程序崩溃感到非常沮丧。

In the main function, I removed everything: 在main函数中,我删除了所有内容:

int main(int argc, char **argv, char **envp) {
    return (0);
}

But I do have a lot of directives, variables and functions defined outside of the main functions. 但是我确实有许多在主要功能之外定义的指令,变量和函数。

It only crashes in Release mode on Windows 7. Debug mode on Windows 7 is okay; 它只在Windows 7的发布模式下崩溃。在Windows 7上的调试模式是可以的; Debug and Release modes on Windows XP are both okay. Windows XP上的调试和发布模式都可以。

Since I cannot debug, I don't what to do. 既然我不能调试,我不该做什么。

The error is: 错误是:

Unhandled exception at 0x00dc21ca in MyApp.exe: 0xC0000005: Access violation reading location 0x8496a9bb.

Assembly line: 流水线:

00DC21CA  mov         eax,dword ptr [edx+0Ch] 

This is so crazy, Please help. 这太疯狂了,请帮忙。

Peter 彼得

PS: If I removed everything I defined outside the main, then it's okay. PS:如果我删除了我在主要部分之外定义的所有内容,那么它没关系。

PS: PS:

char* AllocArgsMemory()
{
    return (char*)malloc(2); // works: return NULL
                             // So it seems the malloc has some problems
}

Check all the pointers you are using. 检查您正在使用的所有指针。 They way your app crashes shows that you are dereferencing a null pointer or outside of a pre-allocated memory range(eg array). 它们的应用程序崩溃方式表明您正在取消引用空指针或在预先分配的内存范围之外(例如数组)。 This is probably due to an uninitalized pointer or too large a subscription index. 这可能是由于未经初始化的指针或订阅索引太大。

It does not crash in debug mode, because in debug mode, the debugger usually inits uninitalized memory with a predefined value, eg 0xcccccccc, which does not happen in release mode. 它在调试模式下不会崩溃,因为在调试模式下,调试器通常会在未初始化的内存中使用预定义的值,例如0xcccccccc,这在发布模式下不会发生。

Even if it is a release binary, you should create a full symbol file (.pdb) so you can have a decent callstack when your issue occurs. 即使它是一个发布二进制文件,你也应该创建一个完整的符号文件(.pdb),这样你就可以在出现问题时拥有​​一个不错的callstack。 To get it : start any debugger (WinDbg, Visual Studio, etc.), setup it to stop on access violation exception, start you process with it, it should break when the exception occurs and give you a callstack. 为了得到它:启动任何调试器(WinDbg,Visual Studio等),设置它以停止访问冲突异常,开始使用它进行处理,它应该在异常发生时中断并给你一个callstack。 Remember that a debugger can run anything that can be executed ; 请记住,调试器可以运行任何可以执行的操作; even if you don't have links to source code and local variable values, you may have other usefull informations. 即使您没有源代码和局部变量值的链接,您也可能有其他有用的信息。

Hope it helps. 希望能帮助到你。

It sounds like it may be some of the built settings/properties. 听起来它可能是一些内置的设置/属性。 I don't have a lot to offer you (partially because the lack of information), but if its working in DEBUG mode in windows 7, like setting all the build settings/properties in RELEASE the same as DEBUG. 我没有太多东西可以提供给你(部分是因为缺乏信息),但如果它在Windows 7中以DEBUG模式工作,就像在RELEASE中设置所有构建设置/属性一样与DEBUG相同。 If it works, you know it is an issue with a build setting 如果它有效,您知道它是构建设置的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Windows QueueUserWorkItem C ++发行模式问题 - Windows QueueUserWorkItem C++ Release mode issue 除非在XP兼容模式下运行,否则Windows Vista / 7上的低级C ++应用程序崩溃 - Low-Level C++ App Crashes on Windows Vista/7 Unless Run in XP Compatibility Mode C ++完全系统崩溃,仅限发布模式 - C++ full system crash, release mode only Directshow渲染过滤器仅在发布模式下崩溃 - Directshow render filter crashes only in release mode 仅在Xcode C ++项目中,发布模式下的链接器错误 - Linker error in release mode only in Xcode C++ Project c ++方法参数仅在linux的发布模式下自行更改 - c++ method parameter change it self only in release mode at linux 程序仅在调试器外部的发布模式下崩溃 - Program crashes only in Release mode outside debugger 睡眠仅在调试模式下工作,而不在释放模式下工作(Embarcadero C ++ Builder) - Sleep only working in debug mode, and not release mode (Embarcadero C++ Builder) 当我的程序启动的应用崩溃时,自动放弃Windows msg错误对话框(Win7-32​​,C ++,VSE2013) - Automatically discard windows msg error dialog when app started by my program crashes (Win7-32, C++, VSE2013) MySQL C ++连接器在ResultSet-> getString()时使我的应用程序崩溃 - MySQL C++ Connector crashes my app at ResultSet->getString()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM