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

Show feedback again

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

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

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


Wed 23 Sep 2015 02:15:30 PM UTC, 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>
Wed 23 Sep 2015 12:13:17 PM UTC, 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>
Tue 22 Sep 2015 12:51:31 PM UTC, 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>
Mon 07 Jan 2013 12:01:29 AM UTC, 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 16 Aug 2012 08:47:04 PM UTC, 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.


(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):

No files currently attached


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.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    No Changes Have Been Made to This Item
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup