|
-
November 22nd, 2005, 03:05 PM
#1
Debug Assertion Failed
Hi,
I´m working in a project that uses 3 dlls:
AutoLib.dll
CommLib.dll
GDCP.dll
and an .EXE.
MbConfigurator.
that uses those DLLs implictly linked.
It all compiled and linked fine, but when its running in Debug version, i´m getting this a "debug assertion failed!" when I call:
Code:
func1(){
...
TArrayStream* channelNames; //TArrayStream is a class defined inside autolib.dll
channelNames=mapChannels->ReturnChannelsNames(); //mapchannel is an instance of a class defined inside GDCP.dll
delete channelNames; //when it try to destroy this object
...
}
i´m getting:
Debug Assertion Failed!
File: dbgheap.c
Line: 1132
Expression: _CrtIsValidHeapPointer(pUserData)
the code of ReturnChannelNames:
Code:
TArrayStream* TMapChannels::ReturnChannelsNames(void){
size_t i, qtd;
qtd=channels->GetElQty();
TArrayStream* vector;
if(qtd>0){
TChannelDevices* pChanEncontrado;
vector=new TArrayStream(MAX_CHANNEL_NAME,qtd);
for(i=1;i<=qtd;i++){
char buffer[MAX_CHANNEL_NAME];
channels->Get(i,&pChanEncontrado);
pChanEncontrado->ReturnChannelName(buffer);
vector->Add(buffer);
}
return(vector);
}
return(NULL);
}
I´ve researched, and I´ve founded out that I must run all the project using the same DLL. I´ve made it all the same but the problem won´t go away. Is there any body than can help me?
Thanks,
Adrian
Last edited by cilu; November 22nd, 2005 at 03:50 PM.
Reason: added code tags
-
November 22nd, 2005, 04:18 PM
#2
Re: Debug Assertion Failed
Hi,
See if you are smashing your buffer. Comment out the following:
Code:
char buffer[MAX_CHANNEL_NAME];
memset( buffer, 0x0, MAX_CHANNEL_NAME );
//channels->Get(i,&pChanEncontrado);
//pChanEncontrado->ReturnChannelName(buffer);
vector->Add(buffer);
You might also verify you do not need the following (room for '\0' Terminator?):
Code:
char buffer[MAX_CHANNEL_NAME+1];
Finally, what is the typedef for TArrayStream?
Jeff
-
November 22nd, 2005, 04:25 PM
#3
Re: Debug Assertion Failed
Typically I have encountered this problem if the DLL allocates memory and the application tries to free this allocated memory. The two heaps are different. It's been such a long time since I last encountered this problem but I believe the solution is to match your CRTs.
Go to Project->Settings->Code Generation.
Make sure your app and your DLL are using the same runtime library.
So if your app uses Multithreaded DLL your DLL setting should also be Multithreaded DLL. Also at the same time you need to make sure that your app and DLL are using the same build versions. Hence if your App is built with release build your DLL should also be built using release build. If your App is built with debug build, your DLL should be a debug build as well.
Let me see if I can dig up a previous post I had posted way back a long time ago.
-
November 23rd, 2005, 08:22 AM
#4
Re: Debug Assertion Failed
Hi guys,
Thanks for your help. It worked!!!. The buffer was ok to receive data. It´s been a problem of difference of CRT.
Thaks again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|