Debug Assertion Failed
-
"my application is dialog base application" and i using sample dll. i execute this application.. following error appear... i don't know this error type. Debug Assertion Failed Program:debug\My.exe File:dbgheap.c Line:1011 Expression:_CrtIsValidHeapPointer(pUserData) Debug Assertion Failed Program:debug\My.exe File:dbgheap.c Line:1076 Expression:_pFirstBlock(pHead) Application Error The instruction at "0x10008ba5" refrenced memory at "0xddddddf1":The memory could not be "read".
-
"my application is dialog base application" and i using sample dll. i execute this application.. following error appear... i don't know this error type. Debug Assertion Failed Program:debug\My.exe File:dbgheap.c Line:1011 Expression:_CrtIsValidHeapPointer(pUserData) Debug Assertion Failed Program:debug\My.exe File:dbgheap.c Line:1076 Expression:_pFirstBlock(pHead) Application Error The instruction at "0x10008ba5" refrenced memory at "0xddddddf1":The memory could not be "read".
Your program is trying to free (or delete) a memory location that hasn't been allocated or has already been freed.
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
Your program is trying to free (or delete) a memory location that hasn't been allocated or has already been freed.
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
my code here---------> test.h ------ TEST_API void TestCStringArray(CStringArray* _testarray); test.cpp -------- TEST_API void TestCStringArray(CStringArray* _testarray) { _testarray->Add("test1"); _testarray->Add("test2"); _testarray->Add("test3"); _testarray->Add("test4"); } ============================================================ using dll code here------> typedef void (*EXTERNAL_TESTCSTRINGARRAY) (CStringArray* _testarray); EXTERNAL_TESTCSTRINGARRAY dll_testcstringarray; CStringArray _testarray; dll_testcstringarray(&_testarray); for (int i=0;i<_testarray.GetSize();i++) { m_ist.AddString(_testarray.GetAt(i)); } what i missing? i don't know? how can i solve this error???
-
my code here---------> test.h ------ TEST_API void TestCStringArray(CStringArray* _testarray); test.cpp -------- TEST_API void TestCStringArray(CStringArray* _testarray) { _testarray->Add("test1"); _testarray->Add("test2"); _testarray->Add("test3"); _testarray->Add("test4"); } ============================================================ using dll code here------> typedef void (*EXTERNAL_TESTCSTRINGARRAY) (CStringArray* _testarray); EXTERNAL_TESTCSTRINGARRAY dll_testcstringarray; CStringArray _testarray; dll_testcstringarray(&_testarray); for (int i=0;i<_testarray.GetSize();i++) { m_ist.AddString(_testarray.GetAt(i)); } what i missing? i don't know? how can i solve this error???
Are your DLL and exe both using the same heap? If not your exe may be trying to delete a pointer on its heap which was allocated on the DLLs heap. If you vote me down, my score will only get lower
-
Are your DLL and exe both using the same heap? If not your exe may be trying to delete a pointer on its heap which was allocated on the DLLs heap. If you vote me down, my score will only get lower
can u tell me about heap..(memory allocate) i'm just small programmer. so,i can't handle. how can i keep?
-
can u tell me about heap..(memory allocate) i'm just small programmer. so,i can't handle. how can i keep?
-
Basically, memory allocated by a DLL should be freed by that DLL (not by your EXE). And vice-versa. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com
And therein lies the rub. What Roger was pointing out is exactly what's happening. When adding the
CStringArray
has strings added to it in the DLL, the guts of theCString
s inside theCStringArray
are allocated by the DLL. But then theCStringArray
goes out of scope in the application, the app tries to free it from the heap. Hence, the error :( By the way, this particular error can occur when you overflow an allocated block. Ten gallons of crap doesn't fit in a five gallon bucket (feel free to convert to liters ;)). Bob Ciora -
And therein lies the rub. What Roger was pointing out is exactly what's happening. When adding the
CStringArray
has strings added to it in the DLL, the guts of theCString
s inside theCStringArray
are allocated by the DLL. But then theCStringArray
goes out of scope in the application, the app tries to free it from the heap. Hence, the error :( By the way, this particular error can occur when you overflow an allocated block. Ten gallons of crap doesn't fit in a five gallon bucket (feel free to convert to liters ;)). Bob Cioracan i pass CStringArray from dll. example... CStringArray my(void) { CStringArray a; --- a.Add("a"); a.Add("b"); a.Add("c"); a.Add("d"); -- return a; } i can not pass CStringArray from dll. error C2558: class 'CStringArray' : no copy constructor available i don't know. how can i control CStringArray in dll?
-
can i pass CStringArray from dll. example... CStringArray my(void) { CStringArray a; --- a.Add("a"); a.Add("b"); a.Add("c"); a.Add("d"); -- return a; } i can not pass CStringArray from dll. error C2558: class 'CStringArray' : no copy constructor available i don't know. how can i control CStringArray in dll?
vc-programmer- wrote: can i pass CStringArray from dll. Yes, by reference, as in:
void my (CStringArray& theArray)
{
theArray.Add ("a");
theArray.Add ("b");
...
return;
}However, this won't fix the problem, since the contents of
theArray
will be freed by the client app and not by the DLL as they should. Consider offering another method in your DLL that will clear theCStringArray
's contents. Also consider building a static library instead of a DLL. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com