开发者

App created in Visual Studio on XP 32 crashes 64 on access violation. Recompile in 64 bit environment to find bug, works fine. What?

开发者 https://www.devze.com 2022-12-15 00:40 出处:网络
So I\'ve been developing on Windows XP Visual Studio 2008. I guess it is building my C++ app in 32 bit mode. When I run the program on my new Windows 7 64 bit box, it gets half way through lo开发者_Go

So I've been developing on Windows XP Visual Studio 2008. I guess it is building my C++ app in 32 bit mode. When I run the program on my new Windows 7 64 bit box, it gets half way through lo开发者_Go百科ading a then throws an access violation error. So, I loaded all my development tool and recompiled the project on Windows 7 to find the crash site but it works perfectly! What? How do I make my app work on x64? Do I have to release two seperate versions? I know I can target 64 bit but I don't like two separate executables. I've searched but keep getting the two version solution or everything .net. This is a native C++. is there an x86 flag somewhere?


"Do I have to release two seperate versions?" It depends on what your app does. The majority of 32bit apps work just fine in WoW mode.

"is there an x86 flag somewhere?" Yup. Open up the configuration manager (Alt-B, O) and you will likely see a win32 in the platform selection.

Why your app crashes is going to take some debugging. You should be able to attach the debugger to the 32bit version on the 64bit OS.


Have you considered the possibility that you may be trashing memory? From the way that the application happens to be loaded into memory, it may be that the 32-bit app on 32-bit Windows and the 64-bit app on 64-bit Windows "get lucky", i.e. no important memory locations are overwritten, whereas the 32-bit app on 64-bit Windows is less lucky and crashes.

To find out if you are indeed trashing memory, you can use tools such as Purify and Valgrind.


As the others' answers already said, it is very likely that the application has bugs that are being hidden in one environment. A good tool that has a low cost of entry in terms of learning curve is Microsoft's application verifier. That along with the debugging tools can provide a very good start. Take a look at the gflags utility.

0

精彩评论

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