frustrating crash bug

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • will_asher
    DaJAngband Maintainer
    • Apr 2007
    • 1124

    frustrating crash bug

    I want to get DaJAngband 1.0.98 released, but I've introduced a crash bug somehow and I just can't figure out what's causing it. And I've been real stupid not to make backups of my code often. I'm getting really frustrated with this bug because I've been trying to figure it out for three days now.
    So far I've figure out that it seems to only happen in the town, and I'm pretty sure it's some part of update_stuff, redraw_stuff or window_stuff. I tried to look at everywhere it refers to the monster level or player depth to be sure it's not dividing by 0 and didn't find anywhere it did that.
    I put
    #if isthisit
    #endif
    around suspect recent pieces of my code, but that didn't help.
    I wrote a little function that looks like this:
    Code:
    void did_it_crash_yet(int where)
    {
         /* I know it's crashing in the town */
         if (p_ptr->depth) return;
    
         msg_format("crash yet? %d", where);
         save_player();
    }
    to try to find out where it's crashing but that didn't help. I've tried deleting the .o files and recompiling. I even tried restarting my computer. I wish my compiler would tell me what's causing the crash.

    </venting>
    Will_Asher
    aka LibraryAdventurer

    My old variant DaJAngband:
    http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...)
  • PaulBlay
    Knight
    • Jan 2009
    • 657

    #2
    Originally posted by will_asher
    And I've been real stupid not to make backups of my code often.
    I've been there. At least with a subversion repository you can 'downgrade' to the last working version and then slowly add in the changes you made.
    Currently turning (Angband) Japanese.

    Comment

    • Psi
      Knight
      • Apr 2007
      • 870

      #3
      Is it frequent enough that you can create a reproducible case by saving often until it happens and then using the last savegame to reproduce the problem each time?

      Once you can reproduce it, it should be a lot easier to track down.

      Comment

      • andrewdoull
        Unangband maintainer
        • Apr 2007
        • 872

        #4
        Originally posted by will_asher
        I want to get DaJAngband 1.0.98 released, but I've introduced a crash bug somehow and I just can't figure out what's causing it.
        I suspect you need to install and learn how to use a debugger. That'll allow you to examine the program at the point of the crash, and then determine which line of code the crash is actually occuring in.

        I recommend gdb (although I've not spent the time figuring out how to get it installed and running on my Vista platform) but this depends really on how you're compiling the code.
        The Roflwtfzomgbbq Quylthulg summons L33t Paladins -more-
        In UnAngband, the level dives you.
        ASCII Dreams: http://roguelikedeveloper.blogspot.com
        Unangband: http://unangband.blogspot.com

        Comment

        • Nick
          Vanilla maintainer
          • Apr 2007
          • 9647

          #5
          Originally posted by will_asher
          So far I've figure out that it seems to only happen in the town, and I'm pretty sure it's some part of update_stuff, redraw_stuff or window_stuff. I tried to look at everywhere it refers to the monster level or player depth to be sure it's not dividing by 0 and didn't find anywhere it did that.
          Some things you might try looking at are monster generation in the town, and the day/night change. You have some good advice already, too.
          One for the Dark Lord on his dark throne
          In the Land of Mordor where the Shadows lie.

          Comment

          • zaimoni
            Knight
            • Apr 2007
            • 590

            #6
            Originally posted by will_asher
            I want to get DaJAngband 1.0.98 released, but I've introduced a crash bug somehow and I just can't figure out what's causing it. And I've been real stupid not to make backups of my code often. I'm getting really frustrated with this bug because I've been trying to figure it out for three days now.
            So far I've figure out that it seems to only happen in the town, and I'm pretty sure it's some part of update_stuff, redraw_stuff or window_stuff. ....
            around suspect recent pieces of my code, ....[/code]
            My experience is that if my intuition of what pieces of code were suspect was working for a crash bug, then the crash bug wouldn't exist.

            z-util.h declares plog. Once you have a save that reliably crashes on the very next move:
            * saturate something that calls the suspect function with plog. I'd start with dungeon(), as otherwise I might have to move up the call graph when the suspect function always completes normally.
            * note which plog is right before the crash. Something between that and the next one is calling the actual suspect.
            * Once down to a single statement: remove the old plogs. If the target is another function call, saturate that function with plog ; otherwise, you've found the buggy statement....

            For ISO console applications, you'd normally use printf instead of plog.
            Zaiband: end the "I shouldn't have survived that" experience. V3.0.6 fork on Hg.
            Zaiband 3.0.10 ETA Mar. 7 2011 (Yes, schedule slipped. Latest testing indicates not enough assert() calls to allow release.)
            Z.C++: pre-alpha C/C++ compiler system (usable preprocessor). Also on Hg. Z.C++ 0.0.10 ETA December 31 2011

            Comment

            • PaulBlay
              Knight
              • Jan 2009
              • 657

              #7
              Originally posted by zaimoni
              z-util.h declares plog.
              Where does plog dump its output? (In Windows, that is)

              Personally I'd rather everything from \Angband stayed in \Angband (if you know what I mean) but I seem to recall it was in some folder off in
              \Documents and Settings\[User Name] or something annoying like that.
              Currently turning (Angband) Japanese.

              Comment

              • takkaria
                Veteran
                • Apr 2007
                • 1951

                #8
                Originally posted by PaulBlay
                Where does plog dump its output? (In Windows, that is)

                Personally I'd rather everything from \Angband stayed in \Angband (if you know what I mean) but I seem to recall it was in some folder off in
                \Documents and Settings\[User Name] or something annoying like that.
                It goes to the screen in a message box (see main-win.c:4391).
                takkaria whispers something about options. -more-

                Comment

                • PaulBlay
                  Knight
                  • Jan 2009
                  • 657

                  #9
                  Originally posted by takkaria
                  It goes to the screen in a message box (see main-win.c:4391).
                  Thanks. I must have been thinking of an entirely different message logging thing.
                  Currently turning (Angband) Japanese.

                  Comment

                  • will_asher
                    DaJAngband Maintainer
                    • Apr 2007
                    • 1124

                    #10
                    When I try putting a bunch of plogs, it seems to crash in a different place each time.
                    I tried downloading gdb, but I can't figure out how to use it. There's no executible and the readme file says to type 'configure' then 'make' neither of which do anything. (Is there maybe a debugger that's easier to use?)
                    Will_Asher
                    aka LibraryAdventurer

                    My old variant DaJAngband:
                    http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...)

                    Comment

                    • Nick
                      Vanilla maintainer
                      • Apr 2007
                      • 9647

                      #11
                      Originally posted by will_asher
                      I tried downloading gdb, but I can't figure out how to use it. There's no executible and the readme file says to type 'configure' then 'make' neither of which do anything. (Is there maybe a debugger that's easier to use?)
                      FWIW, the way I have used gdb in windows is to set up mingw/msys and then run gdb in that. If you not already compiling this way, though, there should be a debugger that's more appropriate for your compilation method - something that comes with your compile environment, maybe?
                      One for the Dark Lord on his dark throne
                      In the Land of Mordor where the Shadows lie.

                      Comment

                      • PaulBlay
                        Knight
                        • Jan 2009
                        • 657

                        #12
                        Originally posted by will_asher
                        (Is there maybe a debugger that's easier to use?)
                        If you are, or could be, using Windows then I recommend VC++. Microsoft Visual C++ 2008 Express Edition is available free.

                        Compiling With Visual C++ (IDE)

                        * Start the VC++ IDE and create a new empty project in the source directory (a new subfolder will be created)
                        * Copy angband.ico to the src\win subdirectory.
                        * Add all the *.c, *.h and *.rc files from the \src directory and the win subdirectory.
                        * (Optional) You can create a filter named Win in the previous step instead of putting all the files into one list. This has the cosmetic benefit of more closely resembling the arrangement of files on the disk.

                        Build -> Configuration manager
                        * Set 'configuration' to "Debug". (It's the default)

                        Project -> Properties
                        * Configuration Properties / General : Set "output directory" to where you want the .exe (usually ..\..\ ).
                        * C/C++ / General : Set additional include directories to the source directory (usually ..\ )
                        * C/C++ / General : Set warning level to /W4 (optional).
                        * C/C++ / Advanced : Change "Compile as" to "Compile as C code /TC"
                        * C/C++ / Command Line : Type "/DWINDOWS" into the Command line.
                        * Linker / Input : Set "additional dependencies" to winmm.lib
                        Last edited by PaulBlay; May 22, 2009, 06:25.
                        Currently turning (Angband) Japanese.

                        Comment

                        • Pete Mack
                          Prophet
                          • Apr 2007
                          • 6883

                          #13
                          gdb doesn't work very well on windows. Fortunately, Visual Studio express debugger works very well, and it's free. And you can get a working build environment from Paul!

                          Comment

                          • PaulBlay
                            Knight
                            • Jan 2009
                            • 657

                            #14
                            Originally posted by Pete Mack
                            And you can get a working build environment from Paul!
                            Yeah, well. I just realized that my instructions were for Vanilla Angband but I'm sure they can be fixed.
                            Currently turning (Angband) Japanese.

                            Comment

                            • PaulBlay
                              Knight
                              • Jan 2009
                              • 657

                              #15
                              Originally posted by PaulBlay
                              Yeah, well. I just realized that my instructions were for Vanilla Angband but I'm sure they can be fixed.
                              OK, done that. I tried compiling DaJAngband1097 but got 605 compiler errors when compiling with "Compile as C Code (/TC)" and 195 errors with "Compile as C++ Code (/TP)". Most of the 605 are C89 problems (declaring variables other than at the start of functions).
                              Currently turning (Angband) Japanese.

                              Comment

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