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

StackOverflow https://stackoverflow.com/questions/1962460

Question

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 loading 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?

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top