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. assertion failure

assertion failure

Scheduled Pinned Locked Moved C / C++ / MFC
debugginghelptutorial
7 Posts 5 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.
  • M Offline
    M Offline
    mrby123
    wrote on last edited by
    #1

    When I run my program I got: Debug Assertion Failed! Program: F:\Debug\abvb.exe File: dbgheap.c Line:1044 Expression: _CrtIsValidHeapPointer(pUserData) Please give me a direction on how to find the problem. Thanks

    M C S 3 Replies Last reply
    0
    • M mrby123

      When I run my program I got: Debug Assertion Failed! Program: F:\Debug\abvb.exe File: dbgheap.c Line:1044 Expression: _CrtIsValidHeapPointer(pUserData) Please give me a direction on how to find the problem. Thanks

      M Offline
      M Offline
      Malli_S
      wrote on last edited by
      #2

      As you are getting assert failure, this is for sure that you are using running build of your project. The _CrtIsValidHeapPointer() checks whether the specified address is valid within the local heap. The assert indicates that pUserData doesn't lie in the local heap address space. That may be because, pUserData is not allocated yet or is holding invalid address. It would helpful if you post the full code/function where you get the assert. For more information, have a look at CRT Debugging Techniques[^].

      [Delegates]      [Virtual Desktop]      [Tray Me !]
      -Malli...! :rose:****

      1 Reply Last reply
      0
      • M mrby123

        When I run my program I got: Debug Assertion Failed! Program: F:\Debug\abvb.exe File: dbgheap.c Line:1044 Expression: _CrtIsValidHeapPointer(pUserData) Please give me a direction on how to find the problem. Thanks

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #3

        You just used an invalid pointer. Have a look at the Call Stack window in Visual Studio IDE to locate the offending code. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        A 1 Reply Last reply
        0
        • M mrby123

          When I run my program I got: Debug Assertion Failed! Program: F:\Debug\abvb.exe File: dbgheap.c Line:1044 Expression: _CrtIsValidHeapPointer(pUserData) Please give me a direction on how to find the problem. Thanks

          S Offline
          S Offline
          Stefan_Lang
          wrote on last edited by
          #4

          When I get this problem it's usually due to trying to deallocate a pointer that already has been deallocated. Look at the call stack to find out which object you're trying to deallocate, then check why it's been deallocated already. If this is not called during deallocation then I have no idea, sorry.

          M 1 Reply Last reply
          0
          • C CPallini

            You just used an invalid pointer. Have a look at the Call Stack window in Visual Studio IDE to locate the offending code. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            A Offline
            A Offline
            Albert Holguin
            wrote on last edited by
            #5

            Call stack is the best option in this case... :)

            1 Reply Last reply
            0
            • S Stefan_Lang

              When I get this problem it's usually due to trying to deallocate a pointer that already has been deallocated. Look at the call stack to find out which object you're trying to deallocate, then check why it's been deallocated already. If this is not called during deallocation then I have no idea, sorry.

              M Offline
              M Offline
              mrby123
              wrote on last edited by
              #6

              Thanks for all guys who made suggestion above. When I debug I got error message: "user break point called from code at 0x7c90120e" -> 7C90120E int 3 Please help, Thanks

              S 1 Reply Last reply
              0
              • M mrby123

                Thanks for all guys who made suggestion above. When I debug I got error message: "user break point called from code at 0x7c90120e" -> 7C90120E int 3 Please help, Thanks

                S Offline
                S Offline
                Stefan_Lang
                wrote on last edited by
                #7

                You haven't mentioned what tools you use to develop and debug, but if you got a debugger running, it should automatically open the source code at the position where the error occurs. The message however sounds like it's from internal code, so, most likely, you won't recognize the code as yours. You now need to find out where in your code this function was called. For that you need to check the call stack. If no window is shown for it, see if you can activate it from the menu. If you don't know how to do this, check the help function from your development environment. Once you have the call stack, the focus will likely be on the topmost line, indicating the function that is shown in your source code window. Usually you can make an educated guess what kind of functionality should be performed here from the name of the function. I still suspect you're inside some deallocation routine, but it may be something different; check this! Now scan down the list in the call stack and find the first function that you recognize as part of your own source code. Doubleclick it or do whatever is required to navigate to that position. The source code window will then show the exact location in your source code where another function not from your source code is called. If the problem occurs during deallocation it may be tricky though, as the call may in fact occur at the end of a scope, where stack variables are destroyed. In that case the cursor in the code window may point to a line past the end of the scope; this can be a bit confusing at times... Anyway, once you've located the right location in your code, check the values of the parameters that are involved in the function (or deallocation) call, and see if they have values in the range you expect. Again, if this a deallocation problem, you may not see anything unusual amiss - in this case, if you don't know how to proceed, copy some of the code at that location and post it here.

                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