Re: Debug Assertion Failure



katz911@xxxxxxxxx wrote:
Hello,
I've encountered a strange problem I don't know how to approach.

I've written a program with a MFC interface. Through that interface,
the user can call a function, which has nothing to do with MFC - it's
a function that reads data from a file, and works correctly when I try
to use it in a test, non-mfc program.

When the debugger hits the "return true" line of that function, a
debug assertion failure window pops:
File: dbgheap.c
Line: 1011
Expression: _CrtIsValidHeapPointer(pUserData)

I have no idea what that means, nor why does an MFC error occur in a
"regular" function that doesn't deal with MFC.

Any help would be greatly appreciated,
GK


In a debug build, each time you allocate or free any heap memory the heap manager checks the validity of everything in the heap management structures. This is done to catch an invalid situation as soon as possible. The heap manager is not related to MFC, it is part of the runtime lib used by all C and C++ code in your program. The error probably means a pointer was passed to the heap manager for deletion, and the pointer was not the address of an allocated heap block.

--
Scott McPhillips [MVP VC++]

.



Relevant Pages

  • Re: Mem leak when implement Singleton pattern on CWinApp derived class
    ... see is a misguided attempt to follow mindlessly some abstract idea about design patterns, ... violating any number of assumptions MFC makes about its environment. ... MFC will there EVER be an attempt to create more than one object instance for the CWinApp ... The destructor on a pointer ...
    (microsoft.public.vc.mfc)
  • Re: CDatabase object access violation on DLL Exit
    ... POINTER PASSED TO 'Free'? ... Also, if this is an MFC method, you would need to report the file, line, and VS version ... I have built a regular MFC DLL using shared MFC DLL, ... When a "Free" method gets an AV inside of a destructor, ...
    (microsoft.public.vc.mfc)
  • Re: Works on XP, Crash on 98
    ... I tested out the new mfc71.pdb file by passing a NULL DC pointer to ... The problem is, I'm not using any maps in my code, so it must be ... I searched the mfc src folder for CMapPtrToPtr ... as part of my test code in the thread checks various GDI ...
    (microsoft.public.vc.mfc)
  • Re: Basic question regarding checkboxes
    ... It appears that your real problem is not understanding that the above call is to a C++ member function. ... Your error message shows you are not calling the MFC version of CheckDlgButton but attempting to call the API version. ... The MFC version is a member function of the dialog and it "knows" the HWND of the dialog. ... If you are making this call in some code module that is not part of the dialog then first you have to call that module, passing it the 'this' pointer from the dialog object. ...
    (microsoft.public.vc.mfc)
  • Re: Multithreading and accessing window pointer from thread
    ... Sharing a "window" proper and sharing a MFC ... pass the pointer to a CWnd from one thread to another, ... The handle maps are used to prevent creation of temporary objects. ... example, if you call GetDlgItemfor a window control, you get back ...
    (microsoft.public.vc.mfc)