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. Access violation reading location 0xcdcdcddd.

Access violation reading location 0xcdcdcddd.

Scheduled Pinned Locked Moved C / C++ / MFC
data-structurestoolshelptutorial
10 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.
  • A Offline
    A Offline
    aj1682
    wrote on last edited by
    #1

    Unhandled exception at 0x0044c743 in NewMumsEngine.exe:0xC0000005: Access violation reading location 0xcdcdcddd. This arises in the msgSendQueue method,when I use the semaphore class variable m_pSendLock to access the lockWait()method : m_pSendLock->lockWait(); This happens after the script has been loaded and when the message has to be sent to the queue to be stored.We need to lock to allow only one thread access at a time. Can anyone tell me how to solve this pr atleast what this sort of an error means. Arjun Mukherjee Software Engineer Hewlett Packard

    T D 2 Replies Last reply
    0
    • A aj1682

      Unhandled exception at 0x0044c743 in NewMumsEngine.exe:0xC0000005: Access violation reading location 0xcdcdcddd. This arises in the msgSendQueue method,when I use the semaphore class variable m_pSendLock to access the lockWait()method : m_pSendLock->lockWait(); This happens after the script has been loaded and when the message has to be sent to the queue to be stored.We need to lock to allow only one thread access at a time. Can anyone tell me how to solve this pr atleast what this sort of an error means. Arjun Mukherjee Software Engineer Hewlett Packard

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      Hi There! I think this type of error ususally come when Function pointer is not rightfully initialized or it try to use heap that out of it domainian. aj1682 wrote: m_pSendLock to access the lockWait()method : m_pSendLock->lockWait(); Have you check m_pSendlock is rightfully intialized,before calling of m_pSendLock->lockWait();


      "I Think this Will Help"

      visit me at http://www.thisisalok.tk
      A 1 Reply Last reply
      0
      • T ThatsAlok

        Hi There! I think this type of error ususally come when Function pointer is not rightfully initialized or it try to use heap that out of it domainian. aj1682 wrote: m_pSendLock to access the lockWait()method : m_pSendLock->lockWait(); Have you check m_pSendlock is rightfully intialized,before calling of m_pSendLock->lockWait();


        "I Think this Will Help"

        visit me at http://www.thisisalok.tk
        A Offline
        A Offline
        aj1682
        wrote on last edited by
        #3

        Hi Alok, Thanks for the help. I checked the initialization,m_pSendLock is a semaphore class variable and this is initialised in another class. I have declared a variable of this class and included the semaphore initialization in the constructor of this class. then I have used this variable to access the function of this class where the statement m_pSendLock->lockwait(); is used. So i guess the constructor does the initialization of the semaphore class variable. But I cannot understand the function pointer not rightfully initialised,or the heap out of domain.can u please explain this to me a little and tell me how to check it or any other way. thanks, arjun. Arjun Mukherjee Software Engineer Hewlett Packard

        C T 2 Replies Last reply
        0
        • A aj1682

          Hi Alok, Thanks for the help. I checked the initialization,m_pSendLock is a semaphore class variable and this is initialised in another class. I have declared a variable of this class and included the semaphore initialization in the constructor of this class. then I have used this variable to access the function of this class where the statement m_pSendLock->lockwait(); is used. So i guess the constructor does the initialization of the semaphore class variable. But I cannot understand the function pointer not rightfully initialised,or the heap out of domain.can u please explain this to me a little and tell me how to check it or any other way. thanks, arjun. Arjun Mukherjee Software Engineer Hewlett Packard

          C Offline
          C Offline
          Cedric Moonen
          wrote on last edited by
          #4

          Put a breakpoint (F9) just at the line m_pSendLock->lockwait(); and then debug your program (F5). Look at the state of the variable m_pSendLock to check if everything is correct.

          A 1 Reply Last reply
          0
          • C Cedric Moonen

            Put a breakpoint (F9) just at the line m_pSendLock->lockwait(); and then debug your program (F5). Look at the state of the variable m_pSendLock to check if everything is correct.

            A Offline
            A Offline
            aj1682
            wrote on last edited by
            #5

            Hi Cedric, Thanks for the help. I've already done all that,but how do I look at the state of the variable m_pSendLock(). Can u tell me how to do this and can u also tell me what to expect,or any examples that u can give me will be very helpful. Thanks, Arjun. Arjun Mukherjee Software Engineer Hewlett Packard

            C 1 Reply Last reply
            0
            • A aj1682

              Hi Alok, Thanks for the help. I checked the initialization,m_pSendLock is a semaphore class variable and this is initialised in another class. I have declared a variable of this class and included the semaphore initialization in the constructor of this class. then I have used this variable to access the function of this class where the statement m_pSendLock->lockwait(); is used. So i guess the constructor does the initialization of the semaphore class variable. But I cannot understand the function pointer not rightfully initialised,or the heap out of domain.can u please explain this to me a little and tell me how to check it or any other way. thanks, arjun. Arjun Mukherjee Software Engineer Hewlett Packard

              T Offline
              T Offline
              ThatsAlok
              wrote on last edited by
              #6

              aj1682 wrote: I cannot understand the function pointer not rightfully initialised Ususally this Case arise when we Dynamically Load Function from DLL usig LoadLibrary and GetProcAddress. and Function Pointer is Not properly intialized. aj1682 wrote: the heap out of domain Simple,when function tried to acces heap or memory location which out of it access or not properly initialized.


              "I Think this Will Help"

              visit me at http://www.thisisalok.tk
              1 Reply Last reply
              0
              • A aj1682

                Hi Cedric, Thanks for the help. I've already done all that,but how do I look at the state of the variable m_pSendLock(). Can u tell me how to do this and can u also tell me what to expect,or any examples that u can give me will be very helpful. Thanks, Arjun. Arjun Mukherjee Software Engineer Hewlett Packard

                C Offline
                C Offline
                Cedric Moonen
                wrote on last edited by
                #7

                When your program is stopped on your breakpoint, right click on the variable, and click on QuickWatch. Then you will have a window that will show you the state (and value and mamber variables...) of your class. Look if it well instancied (the adress pointer must look something else than 0x000000 or 0xccccccc or 0xcdcdcdcd ...) something like a 'valid' adress (I cannot tell you what exactly is a 'valid' adress). If this is not the case, maybe your semaphore is not instancied...

                1 Reply Last reply
                0
                • A aj1682

                  Unhandled exception at 0x0044c743 in NewMumsEngine.exe:0xC0000005: Access violation reading location 0xcdcdcddd. This arises in the msgSendQueue method,when I use the semaphore class variable m_pSendLock to access the lockWait()method : m_pSendLock->lockWait(); This happens after the script has been loaded and when the message has to be sent to the queue to be stored.We need to lock to allow only one thread access at a time. Can anyone tell me how to solve this pr atleast what this sort of an error means. Arjun Mukherjee Software Engineer Hewlett Packard

                  D Offline
                  D Offline
                  digwizfox
                  wrote on last edited by
                  #8

                  is the debugger pointing to the line of code that calls lockWait()? Are you sure that m_pSendLock was initialized properly? Usually, that type of crash is associated with a pointer that is A) uninitialized (not set to NULL by default) and B) never set to actually point to an object. xCDCDCDDD is the kind of number that variables sometimes get set to if they were never initialized to 0 or NULL in a class constructor. Always initialize pointers to 0. In this case, obviously, you have to set the pointer to point to some valid object. Are you doing something like the below code to setup your pointer somewhere? m_pSendLock = &theSemaphoreObject; or m_pSendLock = new CSemaphore; If so, what specifically are you doing to set the pointer? Is the crash occurring when your application exits? Another kind of situation that occurs is when you have a thread that doesn't terminate before your class is destroyed (on exit). The object gets destroyed but the thread continues to execuate and then trys to call a function with an invalid pointer.

                  A 1 Reply Last reply
                  0
                  • D digwizfox

                    is the debugger pointing to the line of code that calls lockWait()? Are you sure that m_pSendLock was initialized properly? Usually, that type of crash is associated with a pointer that is A) uninitialized (not set to NULL by default) and B) never set to actually point to an object. xCDCDCDDD is the kind of number that variables sometimes get set to if they were never initialized to 0 or NULL in a class constructor. Always initialize pointers to 0. In this case, obviously, you have to set the pointer to point to some valid object. Are you doing something like the below code to setup your pointer somewhere? m_pSendLock = &theSemaphoreObject; or m_pSendLock = new CSemaphore; If so, what specifically are you doing to set the pointer? Is the crash occurring when your application exits? Another kind of situation that occurs is when you have a thread that doesn't terminate before your class is destroyed (on exit). The object gets destroyed but the thread continues to execuate and then trys to call a function with an invalid pointer.

                    A Offline
                    A Offline
                    aj1682
                    wrote on last edited by
                    #9

                    Hi Yeah the debugger is pointing to m_pSendLock->lockwait();when it gives me the error and breaks. I checked the state of the m_pSendLock variable ,I dont think its initialised,even though I did initialize the class variable(that m_pSendLock is a prt of) to NULL,but it still din't work. The constructor contains the code m_pSendLock = new CXSemaphore(... But then I've used a previously declared and initialised pointer of the same class and then referenced m_pSendLock and all other methods,and it seems to work.I do not understand y so.Anyway, as of now I have solved the problem,even though I do not understand y and how. Thanks a lot. Arjun Mukherjee Software Engineer Hewlett Packard

                    D 1 Reply Last reply
                    0
                    • A aj1682

                      Hi Yeah the debugger is pointing to m_pSendLock->lockwait();when it gives me the error and breaks. I checked the state of the m_pSendLock variable ,I dont think its initialised,even though I did initialize the class variable(that m_pSendLock is a prt of) to NULL,but it still din't work. The constructor contains the code m_pSendLock = new CXSemaphore(... But then I've used a previously declared and initialised pointer of the same class and then referenced m_pSendLock and all other methods,and it seems to work.I do not understand y so.Anyway, as of now I have solved the problem,even though I do not understand y and how. Thanks a lot. Arjun Mukherjee Software Engineer Hewlett Packard

                      D Offline
                      D Offline
                      digwizfox
                      wrote on last edited by
                      #10

                      For future reference, it sure would help to see some code snips of your class declaration, constructor implementation, and maybe some snips of where the instantiated object is used. Regards, Shawn

                      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