I've created a simple Windows Forms Application in MSVS 2005:
- Use MFC in a Shared DLL
- /clr
I inserted the 2nd include for <afxtempl.h> as shown below:
=================================================================
// test1.cpp : main project file.
#include "stdafx.h"
#include <afxtempl.h>
#include "Form1.h"
using namespace test1;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}
==================================================================
The debug build crashes with _CrtIsValidHeapPointer assertion. Releas build is ok. So far didn't have any success in finding out why this happens. Any help will be greatly appreciated. Thx.
The debug build crashes with _CrtIsValidHeapPointer assertion.
An assert is NOT a crash. At least, not yet
Originally Posted by eromascanu
Releas build is ok.
In Release build, asserts are not compiled into the binary, that is why you don't see it.
Originally Posted by eromascanu
So far didn't have any success in finding out why this happens.
Are you saying that this is your complete code? Where does it assert?
When assert fails, you can usually hit a Retry button and get right into your code to examine call stack, variables, etc.
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio: FeinWindows - replacement windows manager for Visual Studio, and more...
/* verify heap before getting size */
if (check_frequency > 0)
if (check_counter == (check_frequency - 1))
{
_ASSERTE(_CrtCheckMemory());
check_counter = 0;
}
else
check_counter++;
_mlock(_HEAP_LOCK); /* block other threads */
__try {
/*
* If this ASSERT fails, a bad pointer has been passed in. It may be
* totally bogus, or it may have been allocated from another heap.
* The pointer MUST come from the 'local' heap.
*/
_ASSERTE(_CrtIsValidHeapPointer(pUserData));
Yes, it's the complete code. Very easy to duplicate the problem. I looked into the call stack, and it doesn't help because practically all the code - except that include <afxtempl.h> - is generated by .NET. The problem came from a bigger project, where I need the CList class which requires <afxtemp.h> header. I peeled off the code until I got this minuscule project that duplicates my problem.
Sorry, can't follow your steps to recreate this assert...
Could you post a complete zipped project?
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio: FeinWindows - replacement windows manager for Visual Studio, and more...
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.