Andrettin / Wyrmsun

Strategy game based on history, mythology and fiction
http://andrettin.github.io/
GNU General Public License v2.0
301 stars 47 forks source link

Segfault in Campaign mode #146

Closed KroArtem closed 7 years ago

KroArtem commented 7 years ago

I was playing Dwarven campaign whilst this segfault happened. Don't know what caused the issue.

TerrainTraversal::PushUnitPosAndNeighboor() error: startUnit's "" (ID 254) (221, 236) type is NULL.

Thread 1 "stratagus-dbg" received signal SIGSEGV, Segmentation fault.
0x0000000000889786 in TerrainTraversal::PushUnitPosAndNeighboor (
    this=0x7fffffffcf30, unit=...)
    at /home/kroartem/SVN/Wyrmgus/src/pathfinder/pathfinder.cpp:127
127     const Vec2i extraTileSize(startUnit->Type->TileWidth - 1, startUnit->Type->TileHeight - 1);
(gdb) bt
#0  0x0000000000889786 in TerrainTraversal::PushUnitPosAndNeighboor (
    this=0x7fffffffcf30, unit=...)
    at /home/kroartem/SVN/Wyrmgus/src/pathfinder/pathfinder.cpp:127
#1  0x0000000000ab618e in UnitFindResource (unit=..., startUnit=..., range=15, 
    resource=10, check_usage=false, deposit=0x4806e7d0, only_harvestable=true, 
    ignore_exploration=false, only_unsettled_area=false)
    at /home/kroartem/SVN/Wyrmgus/src/unit/unit_find.cpp:576
#2  0x00000000007563cf in COrder_Resource::WaitInDepot (this=0x485037c0, 
    unit=...) at /home/kroartem/SVN/Wyrmgus/src/action/action_resource.cpp:1416
#3  0x0000000000756fb9 in COrder_Resource::Execute (this=0x485037c0, unit=...)
    at /home/kroartem/SVN/Wyrmgus/src/action/action_resource.cpp:1702
#4  0x000000000076ad93 in HandleUnitAction (unit=...)
    at /home/kroartem/SVN/Wyrmgus/src/action/actions.cpp:526
#5  0x000000000076b53b in UnitActionsEachCycle<__gnu_cxx::__normal_iterator<CUnit**, std::vector<CUnit*> > > (begin=, end=)
    at /home/kroartem/SVN/Wyrmgus/src/action/actions.cpp:617
#6  0x000000000076b160 in UnitActions ()
    at /home/kroartem/SVN/Wyrmgus/src/action/actions.cpp:662
#7  0x000000000092efc0 in GameLogicLoop ()
    at /home/kroartem/SVN/Wyrmgus/src/stratagus/mainloop.cpp:481
#8  0x000000000092f899 in SingleGameLoop ()
    at /home/kroartem/SVN/Wyrmgus/src/stratagus/mainloop.cpp:701
#9  0x0000000000930140 in GameMainLoop ()
---Type <return> to continue, or q <return> to quit---
    at /home/kroartem/SVN/Wyrmgus/src/stratagus/mainloop.cpp:799
#10 0x00000000007bf76e in StartMap (filename="~save/autosave.sav.gz", 
    clean=false) at /home/kroartem/SVN/Wyrmgus/src/game/game.cpp:197
#11 0x00000000007d5553 in StartSavedGame (filename="~save/autosave.sav.gz")
    at /home/kroartem/SVN/Wyrmgus/src/game/savegame.cpp:216
#12 0x0000000000b1a231 in tolua_stratagus_StartSavedGame00 (tolua_S=0x1c6f010)
    at /home/kroartem/SVN/Wyrmgus/tolua.cpp:1135
#13 0x00007ffff7bb5320 in ?? () from /usr/lib/x86_64-linux-gnu/liblua5.1.so.0
#14 0x00007ffff7bbfeea in ?? () from /usr/lib/x86_64-linux-gnu/liblua5.1.so.0
#15 0x00007ffff7bb577d in ?? () from /usr/lib/x86_64-linux-gnu/liblua5.1.so.0
#16 0x00007ffff7bb4a5e in ?? () from /usr/lib/x86_64-linux-gnu/liblua5.1.so.0
#17 0x00007ffff7bb58eb in ?? () from /usr/lib/x86_64-linux-gnu/liblua5.1.so.0
#18 0x00007ffff7bb13a8 in lua_pcall ()
   from /usr/lib/x86_64-linux-gnu/liblua5.1.so.0
#19 0x000000000096312f in LuaCall (narg=0, clear=1, exitOnError=true)
    at /home/kroartem/SVN/Wyrmgus/src/stratagus/script.cpp:185
#20 0x00000000009634c0 in LuaLoadFile (file="scripts/guichan.lua", strArg="")
    at /home/kroartem/SVN/Wyrmgus/src/stratagus/script.cpp:246
#21 0x00000000009dbec9 in MenuLoop ()
    at /home/kroartem/SVN/Wyrmgus/src/stratagus/stratagus.cpp:313
#22 0x00000000009dc996 in stratagusMain (argc=1, argv=0x7fffffffdb68)
    at /home/kroartem/SVN/Wyrmgus/src/stratagus/stratagus.cpp:821
#23 0x000000000092d7c2 in main (argc=1, argv=0x7fffffffdb68)
---Type <return> to continue, or q <return> to quit---
    at /home/kroartem/SVN/Wyrmgus/src/stratagus/main.cpp:37
KroArtem commented 7 years ago

save.txt

Rename txt to sav.gz :)

Andrettin commented 7 years ago

Thanks for reporting this bug :)

Did the crash happen in a loaded save game?

KroArtem commented 7 years ago

No, it first happened in a newly started campaign. Then it started to happen every time I try to load this savegame.

Andrettin commented 7 years ago

It seems like a a mine died (thus making its unit type NULL), but a worker was kept assigned to it regardless, causing a crash when a function related to the worker's gathering tried to get some information about the mine's unit type. I haven't been able to find out why the worker was kept assigned, but I've made a fix that will prevent the crash itself from happening: https://github.com/Andrettin/Wyrmgus/commit/c0e7709a8aa754f8a4096f69f88020b9595a709f

KroArtem commented 7 years ago

I think this one can be closed.