开发者

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.

In the main function, I removed every开发者_运维问答thing:

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
}


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜