Crash during the mission in real time mode
gdb listing
`Thread 1 "main" received signal SIGSEGV, Segmentation fault.
OpenApoc::BattleHazard::update (this=0x60000000d, state=..., ticks=1)
at /home/atrosha/OpenApoc/game/state/battle/battlehazard.cpp:490
490 if (ticksUntilVisible > 0)
(gdb) info stack
at /home/atrosha/OpenApoc/game/state/battle/battlehazard.cpp:490
state=..., ticks=1)
at /home/atrosha/OpenApoc/game/state/battle/battle.cpp:1675
at /home/atrosha/OpenApoc/game/state/gamestate.cpp:959
at /home/atrosha/OpenApoc/game/ui/tileview/battleview.cpp:1443
initialStage=...) at /home/atrosha/OpenApoc/framework/framework.cpp:584
at /home/atrosha/OpenApoc/game/main.cpp:26`
Hmm, looks like the BattleHazard::update() is being called on a junk object -0x60000000d doesn't look sane for a heap pointer....
I think this is caused by an invalidated iterator: BattleHazard::update
may end up calling BattleHazard::expand
, which in turn can call die()
on a nearby BattleHazard. If the destroyed hazard happens to be the next one in the iteration, then the iterator used in Battle::update
becomes invalid (see https://en.cppreference.com/w/cpp/container/set/erase)
This is the only explanation I can think of
Also, I was finished that mission in realtime mode without any errors later.
So strange.
Nice and fast response. Can I mention you in my next video?
Most helpful comment
536 might fix this but it will be hard to test since this bug occurs once in a blue moon. We should close this issue once we merge the pull request and reopen if the bug persists.