I am compiling a managed C++ DLL ( as Multithreaded Debug and Release DLL, using CLR/CLI with IJW, x86 Debug ) with VS2005 Service Pack 1.
My DLL does NOT even call one CUDA routine, I am just linking it with the cudart.lib and I see in the output debug window that loads cudart.dll and cuda.dll as well as te fatZip.dll and others:
Loaded 'F:\CUDA\bin\cudart.dll', Binary was not built with debug information. Loaded 'F:\CUDA\bin\cuda.dll', Binary was not built with debug information. Loaded 'F:\CUDA\bin\ptxcomp.dll', Binary was not built with debug information. Loaded 'F:\CUDA\bin\fatZip.dll', Binary was not built with debug information.
My app loads dynamically some DLL ( plugins of the program ). Once all DLL plugins where loaded ( invoking LoadLibrary and casting to some internal C++ interfaces ), it runs well 20 seconds… then a VS2005 exception message box appears randomly indicating that CUDA crashed:
Unhandled exception at 0x08a938d1 in myApp.exe: 0xC0000005: Access violation reading location 0x00000000
This is call stack:
cudart.dll!08a938d1() <---error here cudart.dll!08a9b336() ntdll.dll!7c9111a7() ntdll.dll!7c929213() kernel32.dll!7c80c096() kernel32.dll!7c80c18e() crypt32.dll!77a59840() crypt32.dll!77a59819() crypt32.dll!77a59692() ntdll.dll!7c920f46() kernel32.dll!7c80b683() ntdll.dll!7c920f46()
The disassembled code:
> cudart.dll!08a938d1() 08A938BE cmp dword ptr [esp+8],3 08A938C3 jne 08A938DF 08A938C5 mov eax,dword ptr ds:[08AA9EF0h] 08A938CA mov ecx,dword ptr fs:[2Ch] 08A938D1 mov ecx,dword ptr [ecx+eax*4] <--error here, ecx=eax=0 08A938D4 add ecx,0Ch 08A938DA call 08A99E76 08A938DF xor eax,eax 08A938E1 inc eax 08A938E2 ret 0Ch
Of course, if I remove the dependency on cudart.lib my program runs well and does not crash. The curious is that just linking the cudart.lib WITHOUT calling a CUDA function it crashes :wacko:
I have a GeForce 6800 256Mb, ForceWare 97.73, Cuda toolkit+Cuda SDK v0.8, Windows XP x86 SP2 Spanish language, Athlon 64 3500+ mounted in an Asus A8V-deluxe AGP8X motherboard (VIAKT400) and 1Gb of Kingston HyperX DDR400
I think you have some NULL pointer there, because the ECX/EAX are both zero, so the cudart.dll is trying to read data from a NULL pointer.