Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Debug Assertion Failed

Debug Assertion Failed

Scheduled Pinned Locked Moved C / C++ / MFC
debuggingperformancehelp
9 Posts 5 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vc programmer 1
    wrote on last edited by
    #1

    "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".

    R 1 Reply Last reply
    0
    • V vc programmer 1

      "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".

      R Offline
      R Offline
      Ryan Binns
      wrote on last edited by
      #2

      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"

      V 1 Reply Last reply
      0
      • R Ryan Binns

        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"

        V Offline
        V Offline
        vc programmer 1
        wrote on last edited by
        #3

        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???

        R 1 Reply Last reply
        0
        • V vc programmer 1

          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???

          R Offline
          R Offline
          Roger Allen
          wrote on last edited by
          #4

          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

          V 1 Reply Last reply
          0
          • R Roger Allen

            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

            V Offline
            V Offline
            vc programmer 1
            wrote on last edited by
            #5

            can u tell me about heap..(memory allocate) i'm just small programmer. so,i can't handle. how can i keep?

            RaviBeeR 1 Reply Last reply
            0
            • V vc programmer 1

              can u tell me about heap..(memory allocate) i'm just small programmer. so,i can't handle. how can i keep?

              RaviBeeR Offline
              RaviBeeR Offline
              RaviBee
              wrote on last edited by
              #6

              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

              B 1 Reply Last reply
              0
              • RaviBeeR RaviBee

                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

                B Offline
                B Offline
                Bob Ciora
                wrote on last edited by
                #7

                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 the CStrings inside the CStringArray are allocated by the DLL. But then the CStringArray 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

                V 1 Reply Last reply
                0
                • B 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 the CStrings inside the CStringArray are allocated by the DLL. But then the CStringArray 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

                  V Offline
                  V Offline
                  vc programmer 1
                  wrote on last edited by
                  #8

                  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?

                  RaviBeeR 1 Reply Last reply
                  0
                  • V vc programmer 1

                    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?

                    RaviBeeR Offline
                    RaviBeeR Offline
                    RaviBee
                    wrote on last edited by
                    #9

                    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 the CStringArray'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

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups