project-navigation
Personal tools

Author Topic: Crash at end of mission  (Read 3171 times)

Offline FWishbringer

  • Rookie
  • ***
  • Posts: 52
    • View Profile
Crash at end of mission
« on: January 08, 2010, 03:44:01 pm »
I'm using the version from http://ufoai.ninex.info/forum/index.php?topic=2830.msg33021#msg33021

When completing missions, I frequently get the same crash. When it occurs, if I load up a save before the mission, I'm still 100% going to repeat the crash. My only workaround is to auto mission, and try the next after.

The error I get (critical stop popup, with the red X)

Crash popup...
Code: [Select]
Assertation failed!
Program: d:\Games\UFOAI-2.3-dev\ufo.exe
File: D:\UFOai\src\game\g_inventory.c
Line: 249

Expression: ic->item.t

--stuff about debugging--

Relevant code...
Code: [Select]
/**
 * @brief Sends whole inventory through the network buffer.
 * @param[in] playerMask The player mask to determine which clients should receive the event (@c G_VisToPM(ent->visflags)).
 * @param[in] ent Pointer to an actor with inventory to send.
 * @sa G_AppearPerishEvent
 * @sa CL_InvAdd
 */
void G_SendInventory (unsigned int playerMask, edict_t *ent)
{
invList_t *ic;
unsigned short nr = 0;
int j;

/* test for pointless player mask */
if (!playerMask)
return;

for (j = 0; j < gi.csi->numIDs; j++)
for (ic = ent->i.c[j]; ic; ic = ic->next)
nr++;

/* return if no inventory items to send */
if (nr == 0 && ent->type != ET_ITEM)
return;

G_EventInventoryAdd(ent, playerMask, nr);
for (j = 0; j < gi.csi->numIDs; j++)
for (ic = ent->i.c[j]; ic; ic = ic->next) {
/* send a single item */
LINE 249 assert(ic->item.t);
G_WriteItem(ic->item, INVDEF(j), ic->x, ic->y);
}
}

It happens with various loadouts, whether or not I pick up items, etc. I can't find any pattern to say 'this will always repeat it'.

When it does occur, its ALWAYS at the end of the mission. right after the last alien is killed or stunned, and if I saved before it, it will always do it if I load the save back up and replay it.

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: Crash at end of mission
« Reply #1 on: January 08, 2010, 03:53:10 pm »
Code: [Select]
if (nr == 0 && ent->type != ET_ITEM)

this line looks wrong to me - if the item amount is zero - there should be no event at all. also the doxygen says, that the ent is an actor. but i don't have the code here to see it in the context.

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: Crash at end of mission
« Reply #2 on: January 08, 2010, 04:04:29 pm »
Code: [Select]
if (nr == 0 && ent->type != ET_ITEM)

this line looks wrong to me - if the item amount is zero - there should be no event at all. also the doxygen says, that the ent is an actor. but i don't have the code here to see it in the context.

Maybe that && should be a || ?

-geever

Offline FWishbringer

  • Rookie
  • ***
  • Posts: 52
    • View Profile
Re: Crash at end of mission
« Reply #3 on: January 08, 2010, 04:41:25 pm »
I went to the wiki
Obtained the codeblocks setup
Got it set up
Extracted all the pk3 files in the appropriate place
..and am presently running an svn update on the whole thing

Once its done, I'll double check the function after the svn update and see if anything changes, if not, I'll try building it with ||

I uncompressed saves, and verified that the crash is still occurring, so hopefully the save will be compatible or easily made compatible, so I can test the crash after any code changes.

EDIT:
Dawned on me, I could just browse the source tree while waiting on svn update to finish.
It still reads as posted

I took a look around and I'm not sure if || is appropriate, or if it wouldn't be better off as just
Code: [Select]
if (nr == 0)
EDIT:
SVN finished, building stock now. To test if it still occurs on latest svn, though I expect it will, since it has the same line.
« Last Edit: January 08, 2010, 07:24:52 pm by FWishbringer »

Offline FWishbringer

  • Rookie
  • ***
  • Posts: 52
    • View Profile
Re: Crash at end of mission
« Reply #4 on: January 08, 2010, 08:47:28 pm »
Ok, it does still occur in R27889, but didn't on the mission I saved it before. I had to go 4 more missions to get it again.

Once I got it again, I tested exiting and re-entering game, and it still crashed when I finished the new mission (saved right before transport arrived).

Changed && to || and rebuilt, and... got something worse.

Weapons aren't being 'held'. I can see them, the people appear to have them, but they are not usable. Not in the 'current item' slot, and opening inventory doesn't show anything on anyone.

EDIT

Changed the statement to if (nr == 0) and it appears to work, time to complete the mission and see if it crashes again.

EDIT

Ok, same crash back... going to try the other half... if (ent->type != ET_ITEM)

EDIT

Ok, that brings back the missing weapons and items

Since those tests (since the original binary I had was release) were all done in release mode. Rebuilding in debug, and will see if I can attach to it.

EDIT

Debug fails to build, tons of errors regarding an undefined reference to mcount, and a few others. Going to rebuild in release and try attaching.

EDIT

Debugging from the codeblocks IDE isn't allowed if I didn't build debug, time to figure out what needs fixed.
« Last Edit: January 08, 2010, 09:32:27 pm by FWishbringer »

Offline FWishbringer

  • Rookie
  • ***
  • Posts: 52
    • View Profile
Re: Crash at end of mission
« Reply #5 on: January 08, 2010, 10:09:14 pm »
Ok, couldn't figure out how to get a stack trace (nothing I switched on or off was giving a stack).

In addition to that error, if I ignore it, it causes the same error (assertation failed) on another line...

Code: [Select]
/**
 * @brief Write an item to the network buffer
 * @param[in,out] item @c item_t being send through net.
 * @param[in,out] container Container which is being updated with item sent.
 * @param[in] x Position of item in given container.
 * @param[in] y Position of item in given container.
 * @sa CL_NetReceiveItem
 * @sa EV_INV_TRANSFER
 */
void G_WriteItem (item_t item, const invDef_t *container, int x, int y)
{
[color=red]assert(item.t);[/color]
gi.WriteFormat("sbsbbbbs", item.t->idx, item.a, item.m ? item.m->idx : NONE, container->id, x, y, item.rotated, item.amount);
}

Ignoring that fault throws a sig fault.

Think I'm at about my limit here, will await ideas.