Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

_CrtIsValidHeapPointer Assertion in C++/CLI Application Debug mode.

912 views
Skip to first unread message

Art

unread,
Jun 20, 2007, 9:09:40 AM6/20/07
to
Hi,

I am getting _CrtIsValidHeapPointer Assertion in C++/CLI Application
Debug mode in VS 2005.
Expression: _CrtIsValidHeapPointer(pUserData)

******************************
It is breaking in dgbheap.c.

Here are steps:

1) I created application in VS2005 :
Project type - VC++
Visual Studio Installed Template - WindowsFormsApplication.
I added a dialog resource to this project and a class to the dialog
which is MFC dialog class.
I also changed the following project properties and their values:
a) CLR - /clr
b) Use MFC as Shared DLL
c) Linker ->advanced -> CLR Unmanaged Code Check - Apply Unmanaged
Code Check (/CLRUNMANAGEDCODECHECK)


When I run this app in the debug mode I get the assertion with
Expression: _CrtIsValidHeapPointer(pUserData).

Any help/url is appreciated.


Thanks a lot,
Arti

Scott McPhillips [MVP]

unread,
Jun 20, 2007, 12:13:46 PM6/20/07
to

When it hits this have a look at the debugger stack window and double
click on lines that look like your classes. This will often take you to
the exact pointer and code that is causing the problem.

--
Scott McPhillips [MVP VC++]

SvenC

unread,
Jun 20, 2007, 12:47:12 PM6/20/07
to
Hi,

> I am getting _CrtIsValidHeapPointer Assertion in C++/CLI Application
> Debug mode in VS 2005.
> Expression: _CrtIsValidHeapPointer(pUserData)
>

> 1) I created application in VS2005 :
> Project type - VC++
> Visual Studio Installed Template - WindowsFormsApplication.
> I added a dialog resource to this project and a class to the dialog
> which is MFC dialog class.
> I also changed the following project properties and their values:
> a) CLR - /clr
> b) Use MFC as Shared DLL
> c) Linker ->advanced -> CLR Unmanaged Code Check - Apply Unmanaged
> Code Check (/CLRUNMANAGEDCODECHECK)
>
> When I run this app in the debug mode I get the assertion with
> Expression: _CrtIsValidHeapPointer(pUserData).

In this article http://msdn.microsoft.com/msdnmag/issues/06/05/MixAndMatch/
it is explained that the DLL CRT must be used.
Please check your C++ project properties: Code Generation : Runtime library:
Multi-threaded [Debug] DLL (/MD or /MDd)

--
SvenC

Art

unread,
Jun 21, 2007, 1:33:22 AM6/21/07
to
Hi SvenC,
I am using C++ project properties: Code Generation : Runtime library=
Multi-threaded Debug DLL (/MDd)

Here is the call stack:

msvcr80d.dll!_msize_dbg(void * pUserData=0xfb9606fc, int
nBlockUse=2) Line 1473 + 0x30 bytes C++
msvcr80d.dll!_dllonexit_nolock(int (void)* func=0xfbd69d8c, void
(void)* * * pbegin=0x0013eab8, void (void)* * * pend=0x0013eab0) Line
295 + 0xd bytes C
msvcr80d.dll!__dllonexit(int (void)* func=0xfbd69d8c, void (void)* *
* pbegin=0x0013eab8, void (void)* * * pend=0x0013eab0) Line 273 +
0x11 bytes C
> ManagedC++.exe!_onexit(int (void)* func=0x00409b70) Line 110 + 0x1b bytes C
ManagedC++.exe!atexit(void (void)* func=0x00409b70) Line 127 + 0x9
bytes C
ManagedC++.exe!`dynamic initializer for 'g_Allocator''() Line 23 +
0x17 bytes C++
[Managed to Native Transition]
ManagedC++.exe!_initterm(void** pfbegin = 0x0040A384, void pfend = )
Line 130 C++
ManagedC++.exe!
<CrtImplementationDetails>::LanguageSupport::InitializeNative() Line
534 C++
ManagedC++.exe!
<CrtImplementationDetails>::LanguageSupport::_Initialize() Line 680 C+
+
ManagedC++.exe!
<CrtImplementationDetails>::LanguageSupport::Initialize() Line 824 +
0x9 bytes C++
ManagedC++.exe!?.cctor@@$$FYMXXZ() Line 871 + 0x9 bytes C++

On Jun 20, 9:47 pm, "SvenC" <S...@community.nospam> wrote:
> Hi,
>
>
>
> > I am getting _CrtIsValidHeapPointer Assertion in C++/CLI Application
> > Debug mode in VS 2005.
> > Expression: _CrtIsValidHeapPointer(pUserData)
>
> > 1) I created application in VS2005 :
> > Project type - VC++
> > Visual Studio Installed Template - WindowsFormsApplication.
> > I added a dialog resource to this project and a class to the dialog
> > which is MFC dialog class.
> > I also changed the following project properties and their values:
> > a) CLR - /clr
> > b) Use MFC as Shared DLL
> > c) Linker ->advanced -> CLR Unmanaged Code Check - Apply Unmanaged
> > Code Check (/CLRUNMANAGEDCODECHECK)
>
> > When I run this app in the debug mode I get the assertion with
> > Expression: _CrtIsValidHeapPointer(pUserData).
>

> In this articlehttp://msdn.microsoft.com/msdnmag/issues/06/05/MixAndMatch/

Ben Voigt [C++ MVP]

unread,
Jun 21, 2007, 6:48:31 PM6/21/07
to

"Art" <artam...@gmail.com> wrote in message
news:1182404002.6...@n2g2000hse.googlegroups.com...

> Hi SvenC,
> I am using C++ project properties: Code Generation : Runtime library=
> Multi-threaded Debug DLL (/MDd)
>
> Here is the call stack:

Is this the first function called in your DLL? Or have some other functions
already had a chance to corrupt the heap? Maybe some other DLL using the
C++ runtime has done some damage.

Art

unread,
Jun 22, 2007, 1:21:38 AM6/22/07
to
Hi Ben,

It is a Windows Form Application. I am not using any DLL.
Added a MFC Dialog class after which I started getting this assertion
in the debug mode
This assertion comes before executing the code in Main().
The Application works fine in the RELEASE MODE.

Thanks,
Art

mamtasharma

unread,
Jul 17, 2008, 7:59:46 AM7/17/08
to
i am working with VC++ MFC , here while executing the application after perticular scans 7 to 8 , application terminates automatically with error dbgheap.c....._CrtIsValidHeapPointer(pUserData).

i hv got sm clue from this forum and as u told ,when this error hits , i just clicked on call stack to hunt for the actual code causing problem.
here i got LUCAMAPI! 10020ef9().
it may be regarding cameras used with my application.plz suggest me the right solution for the above problem.
what should i do next to avoid this termination of application in b/w the process.
thankyou!

0 new messages