开发者

Program crash in x64, works fine in Win32

开发者 https://www.devze.com 2022-12-20 02:05 出处:网络
I\'m working on an application which builds and runs fine in Win32.However, in x64, it builds but crashes on run.Looking at the code and narrowing down the problem, if I comment out the call to the be

I'm working on an application which builds and runs fine in Win32. However, in x64, it builds but crashes on run. Looking at the code and narrowing down the problem, if I comment out the call to the below function, it runs with no problem.

void vec3_copy (double* v1, const double* v2) {
    v1[0] = v2[0]; v1[1] = v2[1]; v1[2] = v2[2];
}

I'm building in Visual Studio 2008 with the C/C++ compiler. All updates have been installed. Any ideas?

EDIT 1 (to answer comments):

The pointers should be valid, as in Win32, it runs fine. No code is change and a different path is not taken, unless the pointer are somewhat modified because its x64 (will look into this).

Unfortunately, there is no information about the crash. In Windows 7, it simply saying that it is looking for a solution to the problem, finds nothing, and returns in the command prompt. In the event viewer, I was able to find the following information:

Faulting application name: DRR_C.exe, version: 0.0.0.0, time stamp: 0x4b7a1ee1
Faulting module name: DRR_C.exe, version: 0.0.0.0, time stamp: 0x4b7a1ee1
开发者_运维问答Exception code: 0xc0000005
Fault offset: 0x0000000000003950
Faulting process id: 0x16a4
Faulting application start time: 0x01caaec078a9c84a
Faulting application path: D:\Development\gpu\dev\DRR_C\x64\Debug\DRR_C.exe
Faulting module path: D:\Development\gpu\dev\DRR_C\x64\Debug\DRR_C.exe

EDIT 2 (to answer more comments):

Modified the line to,

memcpy(v1, v2, 3 * sizeof(double));

New error info has the same exception code and fault offset.


The fact that it still crashes with memcpy confirms that the source of the bad pointer is elsewhere, as expected.

How big is the application? It looks like somewhere along the line, a pointer was truncated to 32 bits or otherwise corrupted. Most likely you will need to spend some quality time with the debugger to track down the exact location.


The first thing which comes to mind and might have caused this crash is a conversion from pointer to int and then back. On Win32 both pointer and int are 32-bits long, on Win64 pointer is likely to be 64-bits long and int is probably only 32-bits long.

0

精彩评论

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