.NET Framework Bookmark and Share   
 index > 64-Bit .NET Framework Development > Mixed Managed Unamanged debug doesn't run in 64 bit
 

Mixed Managed Unamanged debug doesn't run in 64 bit

We have a binary which references the mix of Managed and Unamanaged code and it works fine
in the release mode in 64 bit environment in Windows Server 2008, but it crashes, if we build debug and try to run it
with a popup, which has a description.

Debug Assertion Failed.
Program:
D:\myprog\myprog.exe
File:f:\dd\vctools\crt_bld\self_64_amd64\crt\src\dbgheap.c
Line:1511

Expression: _CrtIsValidHeapPointer(pUserData)

What am I missing?

-Brajesh

brajeshkumar69
It is telling you that either a pointer you use in the unmanaged code is pointing to garbage or that the heap is destroyed. That's a very common problem with unmanaged code, you'll have to debug it.

Hans Passant.
nobugz
Well, it was complaning about any global static variables and std:string in native code. The solution was to move the declaration and intialization of such variables in the method block, based on Danny Kalev's suggestion. I have written a blog about it at http://www.brajeshseattle.blogspot.com.
Hope, it will help someone save some time.

-Thanks,

-Brajesh
brajeshkumar69
It is telling you that either a pointer you use in the unmanaged code is pointing to garbage or that the heap is destroyed. That's a very common problem with unmanaged code, you'll have to debug it.

Hans Passant.
nobugz

The same binary works fine, if buils the solution in release mode. My guess is that somehow VC compiler in Visual Studio 2008 is
getting confused with dynamic intializers in C++. The debug version works fine Win32. It is a problen only in X64 debug environment.
I used WInDbg to debug it little bit and here is the Call Stack:-

kP
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Windows\system32\KERNEL32.dll -
Child-SP RetAddr Call Site
00000000`0061bb40 00000000`76c11a0a ntdll!RtlValidateHeap+0x78
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Windows\WinSxS\amd64_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.1_none_737233ca1c100ce5\MSVCR90D.dll -
00000000`0061bba0 00000000`66cc395b KERNEL32!HeapValidate+0xa
00000000`0061bbd0 00000000`66cc2e3c MSVCR90D!CrtIsValidHeapPointer+0x4b
00000000`0061bc00 00000000`66cc106e MSVCR90D!msize_dbg+0x12c
00000000`0061bc60 00000000`66cc101d MSVCR90D!_dllonexit+0x7e
00000000`0061bcc0 00000001`809091bf MSVCR90D!_dllonexit+0x2d
00000000`0061bd00 00000001`80909213 NetServerComponents!_onexit(
<function> * func = 0x00000001`80e33100)+0x7f [f:\dd\vctools\crt_bld\self_64_amd64\crt\src\atonexit.c @ 110]
00000000`0061bd50 00000001`80d0399c NetServerComponents!atexit(
<function> * func = 0x00000001`80e33100)+0x13 [f:\dd\vctools\crt_bld\self_64_amd64\crt\src\atonexit.c @ 127]
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll -
00000000`0061bd90 000007fe`f3141242 NetServerComponents!`dynamic initializer for 'CDmsVector<CDnafXferReaderNode>::s_defaultColectee''(void)+0x1c [d:\program files (x86)\microsoft visual studio 9.0\vc\include\xutility @ 618]
00000000`0061bdc0 000007ff`0018ed92 mscorwks!IEE+0xab8e
00000000`0061be50 000007ff`0018e9f7 0x7ff`0018ed92
00000000`0061bf30 000007ff`00180c78 0x7ff`0018e9f7
00000000`0061c020 000007ff`001808aa 0x7ff`00180c78
00000000`0061c150 000007ff`0018046c 0x7ff`001808aa
00000000`0061c1d0 000007fe`f3141802 0x7ff`0018046c
00000000`0061c220 000007fe`f3048433 mscorwks!IEE+0xb14e
00000000`0061c260 000007fe`f3050596 mscorwks!CreateAssemblyNameObject+0x7a9d3
00000000`0061c300 000007fe`f303e947 mscorwks!CreateAssemblyNameObject+0x82b36
00000000`0061c360 000007fe`f30348f1 mscorwks!CreateAssemblyNameObject+0x70ee7
00000000`0061c4b0 000007fe`f34cbe28 mscorwks!CreateAssemblyNameObject+0x66e91

Any help would be appreciated.

-Thanks,

-Brajesh

brajeshkumar69
Sorry, it's nothing exotic. Just standard heap corruption. Good luck.

Hans Passant.
nobugz
Well, it was complaning about any global static variables and std:string in native code. The solution was to move the declaration and intialization of such variables in the method block, based on Danny Kalev's suggestion. I have written a blog about it at http://www.brajeshseattle.blogspot.com.
Hope, it will help someone save some time.

-Thanks,

-Brajesh
brajeshkumar69

You can use google to search for other answers

Custom Search

More Threads

• Avoid Using Interop.excel.dll
• Oracle Error on x64 bit
• saving excel sheet afterchange
• _CONTEXT struct in winnt.h with x64?
• web browser control can not play swf files with the 64-bit version of Vista
• 64 Framework behaves differently
• Compile webservice's App_Code.dll into 32-bit in VS2005
• MSDN 64-bit issue
• Registry virtualization in Windows Vista 64 bits
• FolderBrowserDialog SEHException on 64-bit machine