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. a "user breakpoint..." message i don't understand

a "user breakpoint..." message i don't understand

Scheduled Pinned Locked Moved C / C++ / MFC
debuggingperformancehelptutorialquestion
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.
  • G Offline
    G Offline
    Gerald Mercet
    wrote on last edited by
    #1

    Hi everybody, In my application i have created a simple function which delete memory of specific pointer, you could find its following code: void LoadHistoDB::DeleteHistoNorm() { if(pHistoDBNorm!=NULL) { delete[] pHistoDBNorm; pHistoDBNorm=NULL; } } but when i call this function in debug mode, i could read in a message box this following: "User breakpoint called from code at 0x77f8629c" and when i try to debug step by step (with F11 ) it calls this function: void __cdecl operator delete(void* p) { #if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG) _free_dbg(p, _NORMAL_BLOCK); #else free(p); #endif } and the if condition is verified so i have the message box mentionned above so if someone could explain me where is the problem? thans in advance gerald tell me if you need the whole code

    N 1 Reply Last reply
    0
    • G Gerald Mercet

      Hi everybody, In my application i have created a simple function which delete memory of specific pointer, you could find its following code: void LoadHistoDB::DeleteHistoNorm() { if(pHistoDBNorm!=NULL) { delete[] pHistoDBNorm; pHistoDBNorm=NULL; } } but when i call this function in debug mode, i could read in a message box this following: "User breakpoint called from code at 0x77f8629c" and when i try to debug step by step (with F11 ) it calls this function: void __cdecl operator delete(void* p) { #if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG) _free_dbg(p, _NORMAL_BLOCK); #else free(p); #endif } and the if condition is verified so i have the message box mentionned above so if someone could explain me where is the problem? thans in advance gerald tell me if you need the whole code

      N Offline
      N Offline
      Navin
      wrote on last edited by
      #2

      The "user breakpoint" message usually shows up when something very wrong has happened. Chances are you are trying to delete a pointer that is junk. (Quick question, are you *sure* the pointer is ether NULL or pointing to a valid, deletable block of memory that was allocated using new [] ??) Even a broken clock is right twice a day.

      G 1 Reply Last reply
      0
      • N Navin

        The "user breakpoint" message usually shows up when something very wrong has happened. Chances are you are trying to delete a pointer that is junk. (Quick question, are you *sure* the pointer is ether NULL or pointing to a valid, deletable block of memory that was allocated using new [] ??) Even a broken clock is right twice a day.

        G Offline
        G Offline
        Gerald Mercet
        wrote on last edited by
        #3

        when you tell me about "deletable block of memory that was allocated", what do you mean about "deletable", because you could see in the following code how i allocate memory for this pointer: void LoadHistoDB::AllocHistoNorm(long NumHisto) { DeleteHistoNorm(); pHistoDBNorm=new double[NumHisto]; } do you think when you see the delete function that there is a problem? thanks gerald

        T T 2 Replies Last reply
        0
        • G Gerald Mercet

          when you tell me about "deletable block of memory that was allocated", what do you mean about "deletable", because you could see in the following code how i allocate memory for this pointer: void LoadHistoDB::AllocHistoNorm(long NumHisto) { DeleteHistoNorm(); pHistoDBNorm=new double[NumHisto]; } do you think when you see the delete function that there is a problem? thanks gerald

          T Offline
          T Offline
          Tim Smith
          wrote on last edited by
          #4

          What is pHistoDBNorm initialized to? (i.e. in the constructor). If you don't initialize it to NULL in the constructor, then the first time you call AllocHistoNorm, then it will try to delete trash. Tim Smith I'm going to patent thought. I have yet to see any prior art.

          G 1 Reply Last reply
          0
          • T Tim Smith

            What is pHistoDBNorm initialized to? (i.e. in the constructor). If you don't initialize it to NULL in the constructor, then the first time you call AllocHistoNorm, then it will try to delete trash. Tim Smith I'm going to patent thought. I have yet to see any prior art.

            G Offline
            G Offline
            Gerald Mercet
            wrote on last edited by
            #5

            I initialize to NULL in the constructor, the problem arrive when i don't want to use pHistoDBNorm anymore i want to delete memory, and it doesn't work!!!

            R 1 Reply Last reply
            0
            • G Gerald Mercet

              I initialize to NULL in the constructor, the problem arrive when i don't want to use pHistoDBNorm anymore i want to delete memory, and it doesn't work!!!

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

              As your deleting an array, you may find that you have written beyond the range of allocated memory such as: char *p = new char[100]; p[-1] = '\0' ; // error p[100] = 'H'; // error This can cause breakpoints when deallocating the memory, as in debug mode special buffers are placed before and after you allocated data to check for this kind of thing. Roger Allen Sonork 100.10016 In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!

              1 Reply Last reply
              0
              • G Gerald Mercet

                when you tell me about "deletable block of memory that was allocated", what do you mean about "deletable", because you could see in the following code how i allocate memory for this pointer: void LoadHistoDB::AllocHistoNorm(long NumHisto) { DeleteHistoNorm(); pHistoDBNorm=new double[NumHisto]; } do you think when you see the delete function that there is a problem? thanks gerald

                T Offline
                T Offline
                Toni78
                wrote on last edited by
                #7

                When you call DeleteHistoNorm() you check to see if pHistoDBNorm is NULL or not. The thing is that when you declare double *pHistoDBNorm, just to be safe in your class constructor you should set pHistoDBNorm = NULL. I don't know if you are using this pointer somewhere else in your source code without initializing it and then all of a sudden you try to delete it. none

                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