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 Violations

Access Violations

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestiondebugging
14 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.
  • J Offline
    J Offline
    Jack Handy
    wrote on last edited by
    #1

    I have been getting access violations lately. To fix it all I have to do is delete all the object files in the Debug\ directory and recompile. After doing this everything works fine. My question is, Is this normal? Does this happen to other people too or do I have another problem that needs addressing? -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.

    T N R R 4 Replies Last reply
    0
    • J Jack Handy

      I have been getting access violations lately. To fix it all I have to do is delete all the object files in the Debug\ directory and recompile. After doing this everything works fine. My question is, Is this normal? Does this happen to other people too or do I have another problem that needs addressing? -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.

      T Offline
      T Offline
      Tom Archer
      wrote on last edited by
      #2

      From what you're describing your dependencies are out of whack. This is generally solved by doing a Rebuild All (or delete all binaries and Build as you did). However, you need to find out why an incremental build is not building the binaries that need to be built for the app to run. I know this isn't a complete answer, but maybe it will help you in terms of looking in a given direction. Cheers, Tom Archer Author, Inside C# Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.

      J 1 Reply Last reply
      0
      • T Tom Archer

        From what you're describing your dependencies are out of whack. This is generally solved by doing a Rebuild All (or delete all binaries and Build as you did). However, you need to find out why an incremental build is not building the binaries that need to be built for the app to run. I know this isn't a complete answer, but maybe it will help you in terms of looking in a given direction. Cheers, Tom Archer Author, Inside C# Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.

        J Offline
        J Offline
        Jack Handy
        wrote on last edited by
        #3

        Thanks. Now that I know it isn't normal I will look into solving it. Just incase it proves to be a hard solution, Is there a problem besides being annoying with the method I have been using? -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.

        T 1 Reply Last reply
        0
        • J Jack Handy

          Thanks. Now that I know it isn't normal I will look into solving it. Just incase it proves to be a hard solution, Is there a problem besides being annoying with the method I have been using? -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.

          T Offline
          T Offline
          Tom Archer
          wrote on last edited by
          #4

          Jack Handy wrote: Now that I know it isn't normal I will look into solving it. Just incase it proves to be a hard solution, Is there a problem besides being annoying with the method I have been using No. It's just a pain (in terms of time) to have to rebuild all the time. However, it certainly doesn't hurt anything. Cheers, Tom Archer Author, Inside C# Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.

          1 Reply Last reply
          0
          • J Jack Handy

            I have been getting access violations lately. To fix it all I have to do is delete all the object files in the Debug\ directory and recompile. After doing this everything works fine. My question is, Is this normal? Does this happen to other people too or do I have another problem that needs addressing? -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.

            N Offline
            N Offline
            Neville Franks
            wrote on last edited by
            #5

            Jack this definitely isn't normal. In fact I've never seen anything like this and I work in VC++ a zillion hours a day, every day. It sounds like an out and out problem which is only randomly rearing its head, and doing a clean build makes it *appear* to go away. Is the violation address consistent? If you are using a lesser version of Windows (not NT,2K,XP), then once something like this happens it can continue to happen until you reboot. Try and run your app under the Debugger at all times, then when you have a problem like this you can step right in and hopefully track it down. It could be a pointer which isn't pointing anywhere valid. If you have exception handling code in your app you should be picking up most if not all problems like this. Neville Franks, Author of ED for Windows. www.getsoft.com

            J 1 Reply Last reply
            0
            • J Jack Handy

              I have been getting access violations lately. To fix it all I have to do is delete all the object files in the Debug\ directory and recompile. After doing this everything works fine. My question is, Is this normal? Does this happen to other people too or do I have another problem that needs addressing? -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.

              R Offline
              R Offline
              Ravi Bhavnani
              wrote on last edited by
              #6

              I agree with Neville. It looks like there may be something awry in your code. /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

              J 1 Reply Last reply
              0
              • N Neville Franks

                Jack this definitely isn't normal. In fact I've never seen anything like this and I work in VC++ a zillion hours a day, every day. It sounds like an out and out problem which is only randomly rearing its head, and doing a clean build makes it *appear* to go away. Is the violation address consistent? If you are using a lesser version of Windows (not NT,2K,XP), then once something like this happens it can continue to happen until you reboot. Try and run your app under the Debugger at all times, then when you have a problem like this you can step right in and hopefully track it down. It could be a pointer which isn't pointing anywhere valid. If you have exception handling code in your app you should be picking up most if not all problems like this. Neville Franks, Author of ED for Windows. www.getsoft.com

                J Offline
                J Offline
                Jack Handy
                wrote on last edited by
                #7

                Hmmm, so you don't agree with Tom? (see above) Because that was along the lines of what I was thinking. -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.

                1 Reply Last reply
                0
                • R Ravi Bhavnani

                  I agree with Neville. It looks like there may be something awry in your code. /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

                  J Offline
                  J Offline
                  Jack Handy
                  wrote on last edited by
                  #8

                  Hmmm, so you don't agree with Tom? (see above) Because that was along the lines of what I was thinking. -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.

                  N R 2 Replies Last reply
                  0
                  • J Jack Handy

                    Hmmm, so you don't agree with Tom? (see above) Because that was along the lines of what I was thinking. -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.

                    N Offline
                    N Offline
                    Neville Franks
                    wrote on last edited by
                    #9

                    Jack Handy wrote: Hmmm, so you don't agree with Tom? (see above) Because that was along the lines of what I was thinking. Tom wrote: However, you need to find out why an incremental build is not building the binaries that need to be built for the app to run. I certainly agree with this, but in my experience VC doesn't get this wrong as long as you've got the project and it's dependencies set up correctly. If you do a Rebuild All and then it happens again and none of the dependant code has changed, then me thinks it must be a problem in your code. Neville Franks, Author of ED for Windows. www.getsoft.com

                    J 1 Reply Last reply
                    0
                    • N Neville Franks

                      Jack Handy wrote: Hmmm, so you don't agree with Tom? (see above) Because that was along the lines of what I was thinking. Tom wrote: However, you need to find out why an incremental build is not building the binaries that need to be built for the app to run. I certainly agree with this, but in my experience VC doesn't get this wrong as long as you've got the project and it's dependencies set up correctly. If you do a Rebuild All and then it happens again and none of the dependant code has changed, then me thinks it must be a problem in your code. Neville Franks, Author of ED for Windows. www.getsoft.com

                      J Offline
                      J Offline
                      Jack Handy
                      wrote on last edited by
                      #10

                      Neville Franks wrote: If you do a Rebuild All and then it happens again and none of the dependant code has changed, then me thinks it must be a problem in your code. It only happens if I do a normal build (F7) but is fine after I rebuild all. -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.

                      N 1 Reply Last reply
                      0
                      • J Jack Handy

                        Neville Franks wrote: If you do a Rebuild All and then it happens again and none of the dependant code has changed, then me thinks it must be a problem in your code. It only happens if I do a normal build (F7) but is fine after I rebuild all. -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.

                        N Offline
                        N Offline
                        Neville Franks
                        wrote on last edited by
                        #11

                        I don't know if this really getting anyone anywhere. Why don't you jump into the debugger and track down the exception. Neville Franks, Author of ED for Windows. www.getsoft.com

                        1 Reply Last reply
                        0
                        • J Jack Handy

                          Hmmm, so you don't agree with Tom? (see above) Because that was along the lines of what I was thinking. -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.

                          R Offline
                          R Offline
                          Ravi Bhavnani
                          wrote on last edited by
                          #12

                          Tom is right in that you're likely run into weird behavior if VC++ doesn't get the dependencies right. And a "rebuild all" forces recompilation of all modules, thereby getting around a bad dependency check. But I suspect the real problem may lie in the code. I've often run into annoying situations (my fault) when I forget to delete an unused #define from resource.h. It causes no end of problems until I figure out that I'm calling GetDlgItem() with a bogus id. Although the ASSERTs I liberally sprinkle my code with will usually catch that. But annoying all the same. :) /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

                          T 1 Reply Last reply
                          0
                          • R Ravi Bhavnani

                            Tom is right in that you're likely run into weird behavior if VC++ doesn't get the dependencies right. And a "rebuild all" forces recompilation of all modules, thereby getting around a bad dependency check. But I suspect the real problem may lie in the code. I've often run into annoying situations (my fault) when I forget to delete an unused #define from resource.h. It causes no end of problems until I figure out that I'm calling GetDlgItem() with a bogus id. Although the ASSERTs I liberally sprinkle my code with will usually catch that. But annoying all the same. :) /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

                            T Offline
                            T Offline
                            Tom Archer
                            wrote on last edited by
                            #13

                            Very good point, Ravi. That's why while it doesn't hurt anything to do rebuilds, I let him know that it's probably a dependency issue so that he can start looking in that area. Cheers, Tom Archer Author, Inside C# A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.

                            1 Reply Last reply
                            0
                            • J Jack Handy

                              I have been getting access violations lately. To fix it all I have to do is delete all the object files in the Debug\ directory and recompile. After doing this everything works fine. My question is, Is this normal? Does this happen to other people too or do I have another problem that needs addressing? -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.

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

                              It may be worth checking your clocks date/time and seeing if its set to earlier then some of the .cpp/.h files of your project. This can cause the project to only build partially after a change and link using old .obj files. Roger Allen Sonork 100.10016 If I had a quote, it would be a very good one.

                              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