One line makes my program exit with an assertion error:
Debug assertion failed in dbgheap.c
Program: myprogram.exe
File: dbgheap.c
Line: 1044
Expression: _CrtIsValidHeapPointer(pUserData)
What I've got is this:
myprogram.exe calling mydll.dll. mydll.dll contains of more files including
this code:
File 1: (c-file)
// Critical sections for secure access of global variables
HANDLE MutexComPort = NULL;
HANDLE MutexTransmitQ = NULL;
HANDLE MutexRxQ = NULL;
HANDLE MutexProtState = NULL;
HANDLE EventTransmitQFilled = NULL;
HANDLE EventRxQFilled = NULL;
HANDLE EventConnected = NULL;
File 1 (header)
extern HANDLE MutexTransmitQ
extern HANDLE MutexComPort;
extern HANDLE MutexRxQ;
extern HANDLE MutexProtState;
extern HANDLE EventTransmitQFilled;
extern HANDLE EventRxQFilled;
extern HANDLE EventConnected;
File 2:
In a init-function:
if ((EventConnected = CreateEvent((LPSECURITY_ATTRIBUTES) NULL,
TRUE, // flag for manual-reset event
FALSE, // flag for initial state
NULL // pointer to event-object name
)) == NULL) {
return 34; // Error creating Connected indicator
event
}
SetEvent(EventConnected);
In a termination-function
ResetEvent(EventConnected);
Or
CloseHandle(EventConnected);
And even
EventConnected=NULL;
I can reset and close the other events without any problems but if I reset
or close the EventConnected my program fails. I can reset the EventConnected
only if it will be set again in the next line! Anybody got any idea?
Both my exe and my dll are build in debug-mode, I've only got one dll, I'm
compiling both the exe and the dll using shared MFC in a shared dll (but
have also tried to compile without using MFC)!
Hope anybody can help me because I've spend a LOT of time trying to solve
this problem!
/Laurits
The assert is telling you that there is something wrong with your program.
You have done something illegal and, rather than silently continuing, the
C run time is loudly telling you about the problem. This is very nice.
Since it is saying that pUserData is not a valid heap pointer, that probably
means that you are passing in a bad value to free, realloc or delete. Maybe you
are freeing memory twice, or maybe you have an uninitialized pointer that
you are calling free, realloc or delete on.
You also need to double and triple check that your DLL and executable are
using the same versions of the C run time. If they aren't then you will get
this error if you allocate memory in (for instance) the executable and then
free it in the DLL.
"Bruce Dawson" <comm...@cygnus-software.com> skrev i en meddelelse
news:3C13D261...@cygnus-software.com...