Bug #1741
openServer crash due to animal kingdom ai
0%
Description
I'm playing on 3.1.5+, with a custom scenario/ruleset (that uses to work fine), and the server always crashes when I load my savegame and press end turn (on turn 12).
The crash seems to be caused by the ai of the Animal Kingdom. When I edit the ruleset to give 0 move points to every animal unit, then I can continue the savegame without crashes.
This is the full backtrace:
#0 invasion_funct (ait=ait@entry=0x555555bed6c0 <ai_types>, punit=punit@entry=0x5555577b7ed0, dest=dest@entry=true, radius=radius@entry=0, which=1) at aiunit.c:1033
_dummy_x = <optimized out>
tile1_index = 0
tile1 = <optimized out>
tile1_start = 0x0
dummy_y = <optimized out>
tile1_dummy_x = <optimized out>
tile1dummy_y = <optimized out>
_start_dummy_x = <optimized out>
_startdummy_y = <optimized out>
tile1_max = 0
ptile = 0x0
pplayer = 0x5555580f2cf0
__FUNCTION__ = "invasion_funct"
#1 0x00005555556f71b2 in find_something_to_kill (ait=ait@entry=0x555555bed6c0 <ai_types>, pplayer=pplayer@entry=0x5555580f2cf0, punit=punit@entry=0x5555579384a0,
pdest_tile=pdest_tile@entry=0x7fffffffd3f0, ppath=ppath@entry=0x7fffffffd3f8, pferrymap=pferrymap@entry=0x0, pferryboat=0x7fffffffd400, pboattype=0x0,
pmove_time=0x0) at aiunit.c:1243
atype = <optimized out>
aunit_iter = 0x5555577b8590
aunit = 0x5555577b7ed0
attack_value = 3
parameter = {map = 0x0, start_tile = 0x0, moves_left_initially = 0, fuel_left_initially = 0, transported_by_initially = 0x100000001,
cargo_depth = 1438676192, cargo_types = {vec = "UU\000\000\240&\"XUU\000\000\006\000\000\000\001", '\000' <repetidos 14 veces>}, move_rate = 0, fuel = 0,
utype = 0x0, owner = 0x0, omniscience = false, get_MC = 0x555500000001, get_move_scope = 0x555556506660 <unit_types+160320>, ignore_none_scopes = 240,
get_TB = 0x1100000001, get_EC = 0x555555895e30 <normal_move>, get_action = 0x555555894da0 <pf_get_move_scope>,
actions = (PF_AA_UNIT_ATTACK | unknown: 0x5572df00), is_action_possible = 0x0, get_zoc = 0x0, is_pos_dangerous = 0x555555895b60 <pf_get_action>,
get_moves_left_req = 0x7fff00000001, get_costs = 0x555555895a40 <pf_action_possible>, data = 0x0}
punit_map = <optimized out>
ferry_map = <optimized out>
pos = {tile = 0x5555015d3f00, turn = 1432169072, moves_left = 21845, fuel_left = 1435065184, total_MC = 6, total_EC = 4, dir_to_next_pos = 4294967295,
dir_to_here = 1435064896}
punit_class = 0x5555564ddad0 <unit_classes+432>
punit_type = 0x555556506660 <unit_types+160320>
punit_tile = 0x5555582226a0
boattype = 0x0
ferryboat = 0x0
pcity = <optimized out>
acity_data = <optimized out>
bcost = <optimized out>
bcost_bal = <optimized out>
handicap = false
unhap = false
harbor = false
go_by_boat = <optimized out>
vulnerability = <optimized out>
benefit = <optimized out>
pdefender = <optimized out>
move_time = <optimized out>
reserves = <optimized out>
attack = <optimized out>
victim_count = <optimized out>
needferry = <optimized out>
bk = 0
want = <optimized out>
best = 0
goto_dest_tile = 0x0
can_occupy = <optimized out>
nmap = <optimized out>
__FUNCTION__ = "find_something_to_kill"
#2 0x00005555556f8a80 in dai_military_attack (ait=ait@entry=0x555555bed6c0 <ai_types>, pplayer=pplayer@entry=0x5555580f2cf0, punit=punit@entry=0x5555579384a0) at aiunit.c:1785
start_tile = <optimized out>
path = 0x0
ferryboat = 0x0
dest_tile = 0x5555582226a0
id = 306
ct = 10
pcity = 0x0
__FUNCTION__ = "dai_military_attack"
#3 0x00005555556fa44a in dai_manage_military (ait=ait@entry=0x555555bed6c0 <ai_types>, nmap=<optimized out>, pplayer=pplayer@entry=0x5555580f2cf0, punit=punit@entry=0x5555579384a0) at aiunit.c:2572
unit_data = 0x555557938600
id = 306
__FUNCTION__ = "dai_manage_military"
#4 0x00005555556fcdd1 in dai_manage_unit (ait=0x555555bed6c0 <ai_types>, pplayer=0x5555580f2cf0, punit=<optimized out>) at aiunit.c:2739
unit_data = <optimized out>
bodyguard = <optimized out>
is_ferry = false
ptype = 0x555556506660 <unit_types+160320>
nmap = <optimized out>
__FUNCTION__ = "dai_manage_unit"
#5 0x00005555556fee22 in dai_manage_units (ait=ait@entry=0x555555bed6c0 <ai_types>, pplayer=pplayer@entry=0x5555580f2cf0) at aiunit.c:2887
punit = 0x5555579384a0
punit_numbers = 0x7fffffffd6c0
punit_index = 0
punit_ul = <optimized out>
punit_size = <optimized out>
__FUNCTION__ = "dai_manage_units"
#6 0x00005555556ebb13 in dai_do_first_activities (ait=0x555555bed6c0 <ai_types>, pplayer=pplayer@entry=0x5555580f2cf0) at aihand.c:758
No locales.
#7 0x00005555556911b7 in cai_do_first_activities (pplayer=0x5555580f2cf0) at classicai.c:450
deftype = <optimized out>
#8 0x00005555555a9a05 in ai_start_phase () at srv_main.c:1078
_plr_ = 0x5555580f2cf0
MY_i = 58
pplayer = 0x5555580f2cf0
__FUNCTION__ = "ai_start_phase"
MY_i = <optimized out>
pplayer = <optimized out>
_plr_ = <optimized out>
#9 begin_phase (is_new_phase=<optimized out>) at srv_main.c:1327
__FUNCTION__ = "begin_phase"
MY_i = <optimized out>
pplayer = <optimized out>
pconn_iter = <optimized out>
pconn = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
_plr_ = <optimized out>
ptile = <optimized out>
ptile_index = <optimized out>
owner = <optimized out>
pcity = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
plrid = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
_plr_ = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
_plr_ = <optimized out>
#10 srv_running () at srv_main.c:2829
i = <optimized out>
is_new_turn = <optimized out>
skip_mapimg = false
save_counter = 1
need_send_pending_events = false
i = <optimized out>
is_new_turn = <optimized out>
skip_mapimg = <optimized out>
need_send_pending_events = <optimized out>
save_counter = <optimized out>
__FUNCTION__ = "srv_running"
pconn_iter = <optimized out>
pconn = <optimized out>
pmapdef = <optimized out>
#11 srv_main () at srv_main.c:3482
__FUNCTION__ = "srv_main"
#12 0x000055555559cfca in main (argc=1, argv=0x7fffffffda28) at civserver.c:486
inx = 1
showhelp = <optimized out>
showvers = <optimized out>
option = <optimized out>
__FUNCTION__ = "main"
Files
Updated by David Fernandez 7 days ago
- File freeciv3.1-civ2civ3_earth-T0012-animalcrash.sav.xz freeciv3.1-civ2civ3_earth-T0012-animalcrash.sav.xz added
Attached the savegame that crashes after pressing end turn.
This is the ruleset used:
https://raw.githubusercontent.com/dftec-es/civ2civ3_earth/master/3.1/civ2civ3_earth-3.1.mpdl
Updated by Marko Lindqvist 7 days ago
- Related to Bug #1695: SIGSEGV from NULL punit->goto_tile added
Updated by Marko Lindqvist 7 days ago
Marko Lindqvist wrote in #note-2:
Unit has ACTIVITY_GOTO but no goto_tile.
This discrepancy seems to come from the savegame already - we can't get to the root cause (that made the savegame broken) with this. In this ticket we can only add sanity checking to the savegame loading. We can do reviews for goto_tile code in separate tickets.
Updated by Marko Lindqvist 7 days ago
- Category set to Server
- Target version set to 3.1.6
Updated by Marko Lindqvist 7 days ago
- File 0006-savegame-Sanity-check-ACTIVITY_GOTO-against-valid-go.patch 0006-savegame-Sanity-check-ACTIVITY_GOTO-against-valid-go.patch added
- Status changed from New to In Review
- Assignee set to Marko Lindqvist
Updated by David Fernandez 6 days ago
Thank you for the patch. The cause of the broken savegame might be the scenario I used to start the game, which uses an old format (and might include some error).
I have started other games with the same scenario and I have ended with the same crash problem (on 3.1, while there seems to be no crashes on 3.2). I attach the scenario (made by me for 2.5) in case you want to take a look.
By the way, what would be the suggested way to update an old scenario?, and how to get a light file format like the scenarios that ship with freeciv releases?
Updated by David Fernandez 6 days ago
I have applied your patch, loaded the problematic savegame, and I was able to continue the game without crashes for several turns, but as soon as I load one of the savegames (auto or manual) made in the previous turns, the game crashes again when I press end turn.
This is the backtrace after loading autosave from turn 15 (there is also a similar crash if I load the autosave from turn 13, that I played without problems until I tried to reload the game at turn 15):
#0 invasion_funct (ait=ait@entry=0x555555bed6c0 <ai_types>, punit=punit@entry=0x555558320370, dest=dest@entry=true, radius=radius@entry=0, which=1) at aiunit.c:1033
_dummy_x = <optimized out>
tile1_index = 0
tile1 = <optimized out>
tile1_start = 0x0
dummy_y = <optimized out>
tile1_dummy_x = <optimized out>
tile1dummy_y = <optimized out>
_start_dummy_x = <optimized out>
_startdummy_y = <optimized out>
tile1_max = 0
ptile = 0x0
pplayer = 0x555558491ab0
__FUNCTION__ = "invasion_funct"
#1 0x00005555556f7242 in find_something_to_kill (ait=ait@entry=0x555555bed6c0 <ai_types>, pplayer=pplayer@entry=0x555558491ab0, punit=punit@entry=0x555557f6c880,
pdest_tile=pdest_tile@entry=0x7fffffffd3f0, ppath=ppath@entry=0x7fffffffd3f8, pferrymap=pferrymap@entry=0x0, pferryboat=0x7fffffffd400, pboattype=0x0,
pmove_time=0x0) at aiunit.c:1243
atype = <optimized out>
aunit_iter = 0x555558320a30
aunit = 0x555558320370
attack_value = 3
parameter = {map = 0xe, start_tile = 0x9abcf59, moves_left_initially = 0, fuel_left_initially = 0, transported_by_initially = 0x100000001,
cargo_depth = 1438676192, cargo_types = {vec = "UU\000\000 \362!XUU\000\000\006\000\000\000\001", '\000' <repetidos 14 veces>}, move_rate = 0, fuel = 0,
utype = 0x0, owner = 0x0, omniscience = false, get_MC = 0x555500000001, get_move_scope = 0x555556506660 <unit_types+160320>, ignore_none_scopes = 176,
get_TB = 0x55555664e301, get_EC = 0x555555895ec0 <normal_move>, get_action = 0x555555894e30 <pf_get_move_scope>,
actions = (PF_AA_UNIT_ATTACK | unknown: 0x5572df00), is_action_possible = 0x0, get_zoc = 0x0, is_pos_dangerous = 0x555555895bf0 <pf_get_action>,
get_moves_left_req = 0x7fff00000001, get_costs = 0x555555895ad0 <pf_action_possible>, data = 0x0}
punit_map = <optimized out>
ferry_map = <optimized out>
pos = {tile = 0x555501ac3990, turn = 1451121968, moves_left = 21845, fuel_left = 1448890768, total_MC = 6, total_EC = 4152338029, dir_to_next_pos = 32767,
dir_to_here = 46}
punit_class = 0x5555564ddad0 <unit_classes+432>
punit_type = 0x555556506660 <unit_types+160320>
punit_tile = 0x55555821f220
boattype = 0x0
ferryboat = 0x0
pcity = <optimized out>
acity_data = <optimized out>
bcost = <optimized out>
bcost_bal = <optimized out>
handicap = false
unhap = false
harbor = false
go_by_boat = <optimized out>
vulnerability = <optimized out>
benefit = <optimized out>
pdefender = <optimized out>
move_time = <optimized out>
reserves = <optimized out>
attack = <optimized out>
victim_count = <optimized out>
needferry = <optimized out>
bk = 0
want = <optimized out>
best = 0
goto_dest_tile = 0x0
can_occupy = <optimized out>
nmap = <optimized out>
__FUNCTION__ = "find_something_to_kill"
#2 0x00005555556f8b10 in dai_military_attack (ait=ait@entry=0x555555bed6c0 <ai_types>, pplayer=pplayer@entry=0x555558491ab0, punit=punit@entry=0x555557f6c880) at aiunit.c:1785
start_tile = <optimized out>
path = 0x0
ferryboat = 0x0
dest_tile = 0x55555821f220
id = 306
ct = 10
pcity = 0x0
__FUNCTION__ = "dai_military_attack"
#3 0x00005555556fa4da in dai_manage_military (ait=ait@entry=0x555555bed6c0 <ai_types>, nmap=<optimized out>, pplayer=pplayer@entry=0x555558491ab0, punit=punit@entry=0x555557f6c880) at aiunit.c:2572
unit_data = 0x555557f6c9e0
id = 306
__FUNCTION__ = "dai_manage_military"
#4 0x00005555556fce61 in dai_manage_unit (ait=0x555555bed6c0 <ai_types>, pplayer=0x555558491ab0, punit=<optimized out>) at aiunit.c:2739
unit_data = <optimized out>
bodyguard = <optimized out>
is_ferry = false
ptype = 0x555556506660 <unit_types+160320>
nmap = <optimized out>
__FUNCTION__ = "dai_manage_unit"
#5 0x00005555556feeb2 in dai_manage_units (ait=ait@entry=0x555555bed6c0 <ai_types>, pplayer=pplayer@entry=0x555558491ab0) at aiunit.c:2887
punit = 0x555557f6c880
punit_numbers = 0x7fffffffd6c0
punit_index = 0
punit_ul = <optimized out>
punit_size = <optimized out>
__FUNCTION__ = "dai_manage_units"
#6 0x00005555556ebba3 in dai_do_first_activities (ait=0x555555bed6c0 <ai_types>, pplayer=pplayer@entry=0x555558491ab0) at aihand.c:758
No locales.
#7 0x00005555556911b7 in cai_do_first_activities (pplayer=0x555558491ab0) at classicai.c:450
deftype = <optimized out>
#8 0x00005555555a9a05 in ai_start_phase () at srv_main.c:1078
_plr_ = 0x555558491ab0
MY_i = 477
pplayer = 0x555558491ab0
__FUNCTION__ = "ai_start_phase"
MY_i = <optimized out>
pplayer = <optimized out>
_plr_ = <optimized out>
#9 begin_phase (is_new_phase=<optimized out>) at srv_main.c:1327
__FUNCTION__ = "begin_phase"
MY_i = <optimized out>
pplayer = <optimized out>
pconn_iter = <optimized out>
pconn = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
_plr_ = <optimized out>
ptile = <optimized out>
ptile_index = <optimized out>
owner = <optimized out>
pcity = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
plrid = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
_plr_ = <optimized out>
MY_i = <optimized out>
pplayer = <optimized out>
_plr_ = <optimized out>
#10 srv_running () at srv_main.c:2829
i = <optimized out>
is_new_turn = <optimized out>
skip_mapimg = false
save_counter = 1
need_send_pending_events = false
i = <optimized out>
is_new_turn = <optimized out>
skip_mapimg = <optimized out>
need_send_pending_events = <optimized out>
save_counter = <optimized out>
__FUNCTION__ = "srv_running"
pconn_iter = <optimized out>
pconn = <optimized out>
pmapdef = <optimized out>
#11 srv_main () at srv_main.c:3482
__FUNCTION__ = "srv_main"
#12 0x000055555559cfca in main (argc=1, argv=0x7fffffffda28) at civserver.c:486
inx = 1
showhelp = <optimized out>
showvers = <optimized out>
option = <optimized out>
__FUNCTION__ = "main"