1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Debugging practices

Discussion in 'Civ5 - SDK / LUA' started by Drawmeus, Dec 29, 2012.

  1. Drawmeus

    Drawmeus Emperor

    Joined:
    Jul 25, 2007
    Messages:
    1,213
    I've run into an apparently random crash bug - it's completely inconsistent when it happens, sometimes it takes 20 turns, sometimes it takes 1.

    It always happens, eventually. I don't know how to debug it.

    It's *probably* happening in my C++ code. I've been over it extensively and completely rewritten the portions that changed between the previous (stable) build and this (unstable) one - I don't see any errors.

    I have attached Visual C++ 2008 to the Civ process and watched it step through breakpoints, and it's ended at a different breakpoint each time - in wildly different classes, often enough, though often in the one I've been working on. Once, it pointed outside the CvGameCoreDLL.

    I'm at my wits end here - I simply don't know how to figure out what's going on.
     
  2. Drawmeus

    Drawmeus Emperor

    Joined:
    Jul 25, 2007
    Messages:
    1,213
    So, this turned out to be a perfect storm (yes, I used the overused cliche, deal with it!) of bad stuff.

    I did two major projects yesterday. One was a large amount of UI code which I tested without cycling very many turns, confirming that each individual piece worked.

    The second was a relatively minor C++ change - the kind that shouldn't be able to cause random crashes. In testing this C++ change, I exposed a crash, but it was extremely inconsistent as to when it would happen. To debug, I attached VC++2008 to the Civ process and stepped through breakpoints throughout my code - and it crashed in various places, often not in my code at all.

    Well, on examining the call stack, the crashes kept being in the lua, so I put print statements all around my lua code (seriously, so many that it slows the game down on performing certain actions). That exposed at least two major but inconsistent crash bugs in the lua code - it turns out they rarely happen in just a turn or two, which is how I had tested the UI changes I made previously.

    So, the reason it seemed random was that it was at least two different errors with code that I thought had already been tested. Woo.
     
  3. General Tso

    General Tso Panzer General

    Joined:
    Oct 12, 2007
    Messages:
    1,547
    Location:
    U. S. of A.
    Been there. Done that. :lol:
     
  4. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,468
    Location:
    Near Portsmouth, UK
    I have a shed full of T-shirts as well :p

    (I'm going to miss these Christmas smilies - can we keep them please ... pretty please!!!!)
     
  5. Drawmeus

    Drawmeus Emperor

    Joined:
    Jul 25, 2007
    Messages:
    1,213
    Debugging this culminated in having a friend (who is a senior/lead level software engineer in the games industry) take control of my computer remotely and start picking through the disassembly panel in VC++ >.>

    But the call stack was really enough info, he was just confirming that the thing that the call stack said was blowing up was in fact the thing that was blowing up. Both bugs fixed now.
     

Share This Page