bugBattle for Wesnoth - Bugs: bug #20071, Segfault when an unit with a...

Show feedback again

You are not allowed to post comments on this tracker with your current authentification level.

bug #20071: Segfault when an unit with a planned action is killed.

Submitted by:  Étienne Simon <ejls>
Submitted on:  Thu Aug 16 20:47:04 2012  
Category: BugSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Whiteboard
Status: NonePrivacy: Public
Assigned to: Étienne Simon <ejls>Open/Closed: Open
Release: r54960Operating System: All

Wed Dec 9 07:10:48 2015, comment #5:

To test the issue with the attached file #25944:

  • Deoddyn at 25,22 is low health.
  • I plan a move to 25,29 so that when I end the turn, he is occupying 26,27.
  • It is then easy for any nearby drake to use their ranged attacks to kill him.
  • After ending the turn, the dead unit's plans are displayed again. Before the PR, the game will crash. Afterwards, the game will not, though it does require a mouse-over the plans to remove it from display (see PR #496 for more explanation on this).
Wedge009 <wedge009>
Project Member
Wed Sep 23 14:15:30 2015, comment #4:

I think I have a reasonable solution. Please see PR #496 for details. If accepted, it will be present in the next development build.

Wedge009 <wedge009>
Project Member
Wed Sep 23 12:13:17 2015, comment #3:

I've managed to reproduce what I think is the original problem:

  • Player 1 has a low-health unit. In planning mode, Player 1 plans a move that takes more than one turn to complete (thus, leaving the low-health unit with planned moves after the current turn).
  • Player 2 attacks the low-health unit, killing it.
  • Back to Player 1's turn, the killed unit still has unfinished planned moves, causing an assertion failure in debug mode, or a terminal crash in normal release compilation.

The crash happens because highlighter::last_action_redraw() attempts to access now-dead unit. I've worked around this by checking first that the unit is valid before attempting to access its data. I am still working on whether its possible (within my limited knowledge of the code) to remove the unfinished planned move highlighting which lingers behind (it ought to be deleted if the unit is no longer alive).

Wedge009 <wedge009>
Project Member
Tue Sep 22 12:51:31 2015, comment #2:

I thought this would be easy to reproduce, but having trouble. Maybe I'm misunderstanding it? I have a low-health unit and plan a move to attack an enemy. Upon ending my turn the unit attacks the enemy, but is killed when the enemy retaliates... and nothing unusual happens?

Wedge009 <wedge009>
Project Member
Mon Jan 7 00:01:29 2013, comment #1:

<un214> is it a known bug that wesnoth crashes when you observe your ally's unit that has a whiteboard move planned die?
<un214> wesnoth: src/whiteboard/move.cpp:364: virtual void wb::move::apply_temp_modifier(unit_map&): Assertion `unit_it != unit_map.end()' failed.
<Alarantalara> Bug #20071 sounds related, but I don't know of any bug report concerning ally's units
<un214> yeah it does sound related
<un214> good chance it's the same bug

Thu Aug 16 20:47:04 2012, original submission:

- Move an unit with 1 hp next to an enemy.
- Plan a move for the next turn.
- End turn.
- When the unit is killed, the game segfault.
With my next commit, the game segfault only on the next use of the highlighter or whatever use action::get_unit before a mapbuilding.
The problem is that the move is not removed from the side_actions.

Étienne Simon <ejls>
Project MemberIn charge of this item.


Attached Files
file #25944:  2p_—_Cynsaun_Battlefield-Sauvegarde_automatique8.gz added by wedge009 (20kB - application/gzip - Save game I used to reproduce this issue and test the PR.)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by wedge009 (Posted a comment)
  • -unavailable- added by ejls (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Error: not logged in



    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed Dec 9 07:07:04 2015wedge009Attached File-=>Added 2p_—_Cynsaun_Battlefield-Sauvegarde_automatique8.gz, #25944
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup