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

发布于 2024-09-30 05:26:40 字数 792 浏览 1 评论 0原文

我对 Windows 7 上的发布模式下的应用程序崩溃感到非常沮丧。

在主函数中,我删除了所有内容:

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

但我确实在主函数之外定义了很多指令、变量和函数。

它仅在 Windows 7 的发布模式下崩溃。 Windows 7 上的调试模式没问题; Windows XP 上的调试和发布模式都可以。

由于我无法调试,我不知道该怎么办。

错误是:

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

装配线:

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

这太疯狂了,请帮忙。

Peter

P.S.:如果我删除了在 main 之外定义的所有内容,那就没问题了。

附:

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

I'm very frustrated with my app crash in Release Mode on Windows 7.

In the main function, I removed everything:

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;
Debug and Release modes on Windows XP are both okay.

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

P.S.: If I removed everything I defined outside the main, then it's okay.

P.S.:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一腔孤↑勇 2024-10-07 05:26:40

检查您正在使用的所有指针。您的应用程序崩溃的方式表明您正在取消引用空指针或超出预分配的内存范围(例如数组)。这可能是由于未初始化的指针或订阅索引太大造成的。

它在调试模式下不会崩溃,因为在调试模式下,调试器通常会使用预定义值(例如0xcccccccc)初始化未初始化的内存,而在释放模式下不会发生这种情况。

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(e.g. 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, e.g. 0xcccccccc, which does not happen in release mode.

风吹雨成花 2024-10-07 05:26:40

即使它是发布二进制文件,您也应该创建一个完整的符号文件 (.pdb),以便在问题发生时可以有一个合适的调用堆栈。
要获取它:启动任何调试器(WinDbg、Visual Studio 等),将其设置为在访问冲突异常时停止,用它启动进程,它应该在异常发生时中断并为您提供调用堆栈。
请记住,调试器可以运行任何可以执行的东西;即使您没有源代码和局部变量值的链接,您也可能有其他有用的信息。

希望有帮助。

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.
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.
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.

公布 2024-10-07 05:26:40

听起来这可能是一些内置的设置/属性。我没有太多可以为您提供的信息(部分是因为缺乏信息),但如果它在 Windows 7 中以 DEBUG 模式工作,例如将 RELEASE 中的所有构建设置/属性设置为与 DEBUG 相同。如果有效,您就知道这是构建设置的问题

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. If it works, you know it is an issue with a build setting

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文