#596964 glob2: Segfault in Unit::syncStep

Package:
glob2
Source:
glob2
Description:
innovative Real Time Strategy game
Submitter:
Guillem Jover
Date:
2010-09-15 12:39:04 UTC
Severity:
important
#596964#5
Date:
2010-09-15 12:31:24 UTC
From:
To:
Hi!

While playing the 4th tuorial level, I got this segfault. It can be
reproduced by loading the autosaved game.

I then used latest hg tree to try to get a proper backtrace, the
problem is, it seems by running that it has changed the format of the
autosave file, which makes 0.9.4.4-2 assert on it now. Hope it's not a
big problem. I'm reporting it anyway as it's a bug present in both
versions anyway.

The problem seems to be that it gets to act on a building which does
not exist anymore. I tried protecting the enemy reference code in
Unit::syncStep but then it segfaulted in Minimap. I'm guessing the
correct fix is to make the action not to happen in the first place by
somehow properly cleaning the enemy building, but then I don't have
visibility of the source organization, so I don't know.

Here's a partial backtrace using hg (identify says 9fcbd36fe414+ tip):

,---
Core was generated by `glob2'.
Program terminated with signal 11, Segmentation fault.
#0  0x00000000007009b0 in Unit::syncStep (this=0x7f9dad89b560)
    at src/Unit.cpp:504
504                                     int degats=getRealAttackStrength()-enemy->type->armor;
(gdb) bt full
#0  0x00000000007009b0 in Unit::syncStep (this=0x7f9dad89b560)
    at src/Unit.cpp:504
        enemyID = 9
        enemyTeam = 1
        degats = 0
        enemy = 0x0
        event = {px = 0x7fff35f60e20, pn = {pi_ = 0x7f9dad8a0140}}
        enemyGBID = 1033
        enemyGUID = 65535
        __PRETTY_FUNCTION__ = "void Unit::syncStep()"
#1  0x00000000006ebe55 in Team::syncStep (this=0x7f9dad864990)
    at src/Team.cpp:979
        u = 0x7f9dad89b560
        i = 23
        isDirtyGlobalGradient = 187
        __PRETTY_FUNCTION__ = "void Team::syncStep()"
        isEnoughFoodInSwarm = 156
        isDying = 187
        nbUsefullUnits = 22
        nbUsefullUnitsAlone = 20
#2  0x00000000004fa418 in Game::syncStep (this=0x7fff35f65588, localTeam=0)
    at src/Game.cpp:1245
        i = 0
        startTick = 11490
        endTick = 905318632
        __PRETTY_FUNCTION__ = "void Game::syncStep(Sint32)"
#3  0x00000000004e5793 in Engine::run (this=0x7fff35f65510)
    at src/Engine.cpp:494
        speed = 40
        networkReadyToExecute = true
        startTime = 8289
        nextGuiStep = 0
        needToBeTime = 3200
        frameNumber = 0
        sendBumpUp = false
        doRunOnceAgain = true
        __PRETTY_FUNCTION__ = "int Engine::run()"
[...]
`---

The autosave file is attached.

regards,
guillem