NPP crash bug under Visual C++ debug compile

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Antoine
    Ironband/Quickband Maintainer
    • Nov 2007
    • 1010

    NPP crash bug under Visual C++ debug compile

    G'day folks

    I downloaded NPP source and Visual C++ 2010 express and used the latter to build the former.

    The Release mode compile seems to work ok.

    The Debug mode compiles, but prints "Restoring dungeon..." and crashes when I load a savefile with "run-time check failure #2, stack around the variable 'vvv' was corrupted".

    I think this might be this bug - http://sourceforge.jp/ticket/browse....4206&tid=16045 - reported by Paul Blay. Paul concludes "just an array bounds problem from when the extra flags were added".

    Any suggestions as to what to do??

    A.
    Ironband - http://angband.oook.cz/ironband/
  • nppangband
    NPPAngband Maintainer
    • Dec 2008
    • 926

    #2
    There are only 6 lines of code associated with the variable [vvv]. It is at the very beginning of the savefile loading functions. Those are the first four bits read out of the savefile. So you shouldn't be too far into load.c before the crash.

    Are you able to isolate the line of code on which the game crashes?
    NPPAngband current home page: http://nppangband.bitshepherd.net/
    Source code repository:
    https://github.com/nppangband/NPPAngband_QT
    Downloads:
    https://app.box.com/s/1x7k65ghsmc31usmj329pb8415n1ux57

    Comment

    • Antoine
      Ironband/Quickband Maintainer
      • Nov 2007
      • 1010

      #3
      Originally posted by nppangband
      There are only 6 lines of code associated with the variable [vvv]. It is at the very beginning of the savefile loading functions. Those are the first four bits read out of the savefile. So you shouldn't be too far into load.c before the crash.

      Are you able to isolate the line of code on which the game crashes?
      It claims to be right at the end of load_player()

      A.
      Ironband - http://angband.oook.cz/ironband/

      Comment

      • nppangband
        NPPAngband Maintainer
        • Dec 2008
        • 926

        #4
        Do you know the exact line?

        By the way, since I am not a skilled programmer who knows how to compile a verision that supports actual de-bugging tools (I really need to learn how to do this), I have a function in NPP called "playtesting", which prints a message in the status line and flushes it, so you have to hit enter to advance beyond that point. If you just scatter lines like this throughout the load_player function like:

        playtesting("breakpoint1");
        playtesting("breakpoint2");
        ......

        you should be able to quickly find the exact line where it crashes in 5-10 minutes. We can probably figure out what is going on from there.

        That is my own way to go line-by-line through the code and find the exact line where the game is crashing.
        NPPAngband current home page: http://nppangband.bitshepherd.net/
        Source code repository:
        https://github.com/nppangband/NPPAngband_QT
        Downloads:
        https://app.box.com/s/1x7k65ghsmc31usmj329pb8415n1ux57

        Comment

        • Antoine
          Ironband/Quickband Maintainer
          • Nov 2007
          • 1010

          #5
          Originally posted by nppangband
          Do you know the exact line?
          It seems to be right at the end of load_player() - presumably while local variables are being cleared up, but before returning control to the calling function. But I think this relates to a problem encountered earlier in the function.

          I think this is mainly just MVC++ being stupidly paranoid. I think it may have a problem with using

          byte vvv[4];

          in

          file_read(fff, (char*)(vvv), 8);

          Perhaps there is a work around that doesn't trigger its ire.

          Thanks for looking at this!
          A.
          Ironband - http://angband.oook.cz/ironband/

          Comment

          • RogerN
            Swordsman
            • Jul 2008
            • 308

            #6
            byte vvv[4];
            ...
            file_read(fff, (char*)(vvv), 8);
            IMO it's a perfectly valid complaint if you're really trying to load 8 bytes of data into 4 bytes of storage

            Comment

            • nppangband
              NPPAngband Maintainer
              • Dec 2008
              • 926

              #7
              Originally posted by RogerN
              IMO it's a perfectly valid complaint if you're really trying to load 8 bytes of data into 4 bytes of storage
              Great point. Now the only mystery to me is why all the rest of us compiling and playing NPP weren't getting orrors or problems opening and closing savefiles.

              Changing this line should help you with visual C++:

              if (!file_read(fff, (char*)(vvv), 4)) err = -1;
              NPPAngband current home page: http://nppangband.bitshepherd.net/
              Source code repository:
              https://github.com/nppangband/NPPAngband_QT
              Downloads:
              https://app.box.com/s/1x7k65ghsmc31usmj329pb8415n1ux57

              Comment

              • nppangband
                NPPAngband Maintainer
                • Dec 2008
                • 926

                #8
                @Antoine:

                I uploaded 0.5.2 (BETA), which fixed some bugs (hopefully including this memory leak error), and makes some minor changes to monster AI. This is in beta as a sanity check, and I should finalize it this weekend.

                Announcement with complete changelist here:



                Here are the links:

                source:


                Windows executable:
                NPPAngband current home page: http://nppangband.bitshepherd.net/
                Source code repository:
                https://github.com/nppangband/NPPAngband_QT
                Downloads:
                https://app.box.com/s/1x7k65ghsmc31usmj329pb8415n1ux57

                Comment

                • myshkin
                  Angband Devteam member
                  • Apr 2007
                  • 334

                  #9
                  Originally posted by nppangband
                  Great point. Now the only mystery to me is why all the rest of us compiling and playing NPP weren't getting orrors or problems opening and closing savefiles.
                  I love the notion of compiler horrors.

                  Comment

                  • Antoine
                    Ironband/Quickband Maintainer
                    • Nov 2007
                    • 1010

                    #10
                    Originally posted by nppangband
                    @Antoine:

                    I uploaded 0.5.2 (BETA), which fixed some bugs (hopefully including this memory leak error), and makes some minor changes to monster AI. This is in beta as a sanity check, and I should finalize it this weekend.
                    Thank you, now my problem is fixed.

                    In the process of compiling NPP, I created a Visual C++ 2010 Express project. This was easy but not trivial. How would you feel about adding it to the source NPP distro?

                    A.
                    Ironband - http://angband.oook.cz/ironband/

                    Comment

                    • ramela
                      Apprentice
                      • Jan 2008
                      • 55

                      #11
                      Ooh, that would make my life easier, since I want to try adding a few new spells.

                      Comment

                      • nppangband
                        NPPAngband Maintainer
                        • Dec 2008
                        • 926

                        #12
                        Originally posted by Antoine
                        Thank you, now my problem is fixed.

                        In the process of compiling NPP, I created a Visual C++ 2010 Express project. This was easy but not trivial. How would you feel about adding it to the source NPP distro?

                        A.
                        I will be happy to add it. Thanks.
                        NPPAngband current home page: http://nppangband.bitshepherd.net/
                        Source code repository:
                        https://github.com/nppangband/NPPAngband_QT
                        Downloads:
                        https://app.box.com/s/1x7k65ghsmc31usmj329pb8415n1ux57

                        Comment

                        • Pete Mack
                          Prophet
                          • Apr 2007
                          • 6883

                          #13
                          Originally posted by nppangband
                          @Antoine:

                          I uploaded 0.5.2 (BETA), which fixed some bugs (hopefully including this memory leak error), and makes some minor changes to monster AI. This is in beta as a sanity check, and I should finalize it this weekend.
                          BTW: buffer overflows are not the same as memory leaks. They are much, much worse. (And they tend to lead to complaints that windows or OSX is not reliable when arguably the opposite that true.)

                          Props to VC++ for catching this at compile time.

                          Comment

                          • Antoine
                            Ironband/Quickband Maintainer
                            • Nov 2007
                            • 1010

                            #14
                            Originally posted by Pete Mack
                            BTW: buffer overflows are not the same as memory leaks. They are much, much worse. (And they tend to lead to complaints that windows or OSX is not reliable when arguably the opposite that true.)

                            Props to VC++ for catching this at compile time.
                            Was actually at run time, but nonetheless.

                            A.
                            Ironband - http://angband.oook.cz/ironband/

                            Comment

                            Working...
                            😀
                            😂
                            🥰
                            😘
                            🤢
                            😎
                            😞
                            😡
                            👍
                            👎