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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Debug Assertion Failed! _CrtIsValidHeapPointer( pUserData)

Debug Assertion Failed! _CrtIsValidHeapPointer( pUserData)

Scheduled Pinned Locked Moved C / C++ / MFC
helpdebuggingtutorial
5 Posts 4 Posters 0 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.
  • S Offline
    S Offline
    Shouvik Das
    wrote on last edited by
    #1

    Hi, I have a Win32 Console Application which is throwing the Debug Assertion Failed! .. _CrtIsValidHeapPointer( pUserData ) and followed by a Debug Assertion Failed! .. _BLOCK_TYPE_IS_VALID(pHead->nBlockUse). After I did a Step by Step Debug strangely what I saw was it is throwing error once it is exittin the main function. Unlike any character pointers and deletion of heap without its references as of when generally this error occurs I have no such instances. please could you suggest a probable solution to this. please help.


    There are only two kinds of people who are really fascinating-people who know absolutely everything, and people who know absolutely nothing. Oscar Wilde (1854-1900) Regards... Shouvik

    J M H 3 Replies Last reply
    0
    • S Shouvik Das

      Hi, I have a Win32 Console Application which is throwing the Debug Assertion Failed! .. _CrtIsValidHeapPointer( pUserData ) and followed by a Debug Assertion Failed! .. _BLOCK_TYPE_IS_VALID(pHead->nBlockUse). After I did a Step by Step Debug strangely what I saw was it is throwing error once it is exittin the main function. Unlike any character pointers and deletion of heap without its references as of when generally this error occurs I have no such instances. please could you suggest a probable solution to this. please help.


      There are only two kinds of people who are really fascinating-people who know absolutely everything, and people who know absolutely nothing. Oscar Wilde (1854-1900) Regards... Shouvik

      J Offline
      J Offline
      Jonathan Darka
      wrote on last edited by
      #2

      Looks like you are trying to delete the same pointer twice, or trying to delete something which is not a pointer to a heap based object. If you can post some of the code, then we can help.


      Jonathan Wilkes Darka [Xanya.net]

      1 Reply Last reply
      0
      • S Shouvik Das

        Hi, I have a Win32 Console Application which is throwing the Debug Assertion Failed! .. _CrtIsValidHeapPointer( pUserData ) and followed by a Debug Assertion Failed! .. _BLOCK_TYPE_IS_VALID(pHead->nBlockUse). After I did a Step by Step Debug strangely what I saw was it is throwing error once it is exittin the main function. Unlike any character pointers and deletion of heap without its references as of when generally this error occurs I have no such instances. please could you suggest a probable solution to this. please help.


        There are only two kinds of people who are really fascinating-people who know absolutely everything, and people who know absolutely nothing. Oscar Wilde (1854-1900) Regards... Shouvik

        M Offline
        M Offline
        Mike Dimmick
        wrote on last edited by
        #3

        The normal debug configuration of a VS C++ project checks the heap hasn't been corrupted when you exit. If these assertions fire, the heap has been corrupted. This is a wild-write bug. Somewhere, you're using a bad pointer, or have made a mistake in pointer calculation, or allocated too little space for a buffer, or written off the end of a buffer. These are very hard to track down. Ensure that you always initialize pointers to NULL or to a real value, so you don't get random stack garbage that could point anywhere. If it's consistently the same address, you can use a data breakpoint to see when the data at that address changes. See 'data breakpoints' in MSDN Library.

        Stability. What an interesting concept. -- Chris Maunder

        1 Reply Last reply
        0
        • S Shouvik Das

          Hi, I have a Win32 Console Application which is throwing the Debug Assertion Failed! .. _CrtIsValidHeapPointer( pUserData ) and followed by a Debug Assertion Failed! .. _BLOCK_TYPE_IS_VALID(pHead->nBlockUse). After I did a Step by Step Debug strangely what I saw was it is throwing error once it is exittin the main function. Unlike any character pointers and deletion of heap without its references as of when generally this error occurs I have no such instances. please could you suggest a probable solution to this. please help.


          There are only two kinds of people who are really fascinating-people who know absolutely everything, and people who know absolutely nothing. Oscar Wilde (1854-1900) Regards... Shouvik

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          And maybe this tool will be helpful for you. Memory(-Leak) and Exception Trace (CRT and COM Leaks)[^]


          WhiteSky


          S 1 Reply Last reply
          0
          • H Hamid Taebi

            And maybe this tool will be helpful for you. Memory(-Leak) and Exception Trace (CRT and COM Leaks)[^]


            WhiteSky


            S Offline
            S Offline
            Shouvik Das
            wrote on last edited by
            #5

            according to the following call stack NTDLL! 7c901230() NTDLL! 7c96cd80() NTDLL! 7c960af8() KERNEL32! 7c85e9cf() _CrtIsValidHeapPointer(const void * 0x00032b78) line 1697 _free_dbg_lk(void * 0x00032b78, int 1) line 1044 + 9 bytes _free_dbg(void * 0x00032b78, int 1) line 1001 + 13 bytes operator delete(void * 0x00032b78) line 351 + 12 bytes CString::FreeData() line 146 + 15 bytes CString::~CString() line 213 $E155() + 34 bytes doexit(int 0, int 0, int 0) line 353 exit(int 0) line 279 + 13 bytes mainCRTStartup() line 345 KERNEL32! 7c816fd7() It is clear the error was occuring tryin to free the CString objects which incidentally I had made global due to the requirements. Hence I refactored my application and passed them as reference. What I inferred from the situation is that while tryin to free up the Cstring memory it encountered that the heap had already been unintiallized. however it is still unclear to me how was the heap cleared before even C Runtime tried to unregister it. I never explicitly have defined any destructors.


            There are only two kinds of people who are really fascinating-people who know absolutely everything, and people who know absolutely nothing. Oscar Wilde (1854-1900) Regards... Shouvik

            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