Merge lp:~widelands-dev/widelands/bug-1636966-segfault-in-battle into lp:widelands
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 8367 | ||||
Proposed branch: | lp:~widelands-dev/widelands/bug-1636966-segfault-in-battle | ||||
Merge into: | lp:widelands | ||||
Diff against target: |
131 lines (+23/-19) 3 files modified
src/logic/map_objects/tribes/battle.cc (+10/-9) src/logic/map_objects/tribes/battle.h (+4/-4) src/logic/map_objects/tribes/soldier.cc (+9/-6) |
||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands/bug-1636966-segfault-in-battle | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Widelands Developers | Pending | ||
Review via email: mp+324365@code.launchpad.net |
Commit message
Assume that we have no battle if the opponent is nullptr. Added some assertions. And a bit of refactoring.
Description of the change
After going through the code, I am making the following assumption: the opponent has died.
These are the commands sent by Battle when a soldier dies:
soldier.
molog("[battle] waking up winner %d\n", opponent(
opponent(
return schedule_
The wakeup signal then ends up leading to the part in the code that crashes. The wakeup is supposed to happen 10 ticks after the Battle is destroyed, but I guess that with very low frametime, this can get its wires crossed. This would also explain the rarity of the crash. I haven't dug really deeply into this part though.
There is already a comment in the code that running the command queue depends on frametime and that it's a bad idea.
I think your argumentation makes sense and it is quite likely that the game was lagging when I encountered the bug. I wasn't able to force the bug by fighting with a low framerate, though.
Diff looks good, too.
When I read the code right, the soldier dies / is deleted after 1 second gametime while the opponent receives the signal after 10 ticks. Seems kind of strange to use two "time"scales in the game, maybe someone should try to clean this up at some time.