full console log makes me wonder if the turn is 55 or 56 ? (because turn 55 was saved before the message)
Game saved as Sz1-Ai002-Lm59-230507_192610-T0054-auto.sav.xz Game saved as Sz1-Ai002-Lm59-230507_192610-T0055-auto.sav.xz 1: in auto_settler_findwork() [../../../server/advisors/autosettlers.c::929]: assertion 'recursion <= unit_list_size(pplayer->units)' failed. 3: Backtrace: 3: 0: /Big/clang-15/FC31/bin/FC31clang-15-server(backtrace+0x5b) [0x55eca457a47b] 3: 1: /Big/clang-15/FC31/bin/FC31clang-15-server(backtrace_print+0x11e) [0x55eca507e11e] 3: 2: /Big/clang-15/FC31/bin/FC31clang-15-server(do_log+0x23a) [0x55eca508d3fa] 3: 3: /Big/clang-15/FC31/bin/FC31clang-15-server(fc_assert_fail+0x188) [0x55eca508d968] 3: 4: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x20f) [0x55eca46d071f] 3: 5: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 6: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 7: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 8: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 9: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 10: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 11: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 12: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 13: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 14: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 15: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 16: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 17: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 18: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 19: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 20: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 21: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 22: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 23: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 24: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 25: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 26: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 27: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 28: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 29: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 30: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 31: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 32: /Big/clang-15/FC31/bin/FC31clang-15-server(dai_auto_settler_run+0x49e2) [0x55eca4c0b482] 3: 33: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settlers_player+0x18d9) [0x55eca46d7929] 3: 34: /Big/clang-15/FC31/bin/FC31clang-15-server(+0x85f790) [0x55eca4620790] 3: 35: /Big/clang-15/FC31/bin/FC31clang-15-server(+0x85a335) [0x55eca461b335] 3: 36: /Big/clang-15/FC31/bin/FC31clang-15-server(srv_main+0x4a4) [0x55eca46158f4] 3: 37: /Big/clang-15/FC31/bin/FC31clang-15-server(main+0x2031) [0x55eca45fe851] 3: 38: /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f1feae29d90] 3: 39: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7f1feae29e40] 3: 40: /Big/clang-15/FC31/bin/FC31clang-15-server(_start+0x25) [0x55eca453cc35] 1: Please report this message at https://osdn.net/projects/freeciv/ticket/ 3: Backtrace: 3: 0: /Big/clang-15/FC31/bin/FC31clang-15-server(backtrace+0x5b) [0x55eca457a47b] 3: 1: /Big/clang-15/FC31/bin/FC31clang-15-server(backtrace_print+0x11e) [0x55eca507e11e] 3: 2: /Big/clang-15/FC31/bin/FC31clang-15-server(do_log+0x23a) [0x55eca508d3fa] 3: 3: /Big/clang-15/FC31/bin/FC31clang-15-server(fc_assert_fail+0x2dd) [0x55eca508dabd] 3: 4: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x20f) [0x55eca46d071f] 3: 5: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 6: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 7: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 8: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 9: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 10: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 11: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 12: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 13: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 14: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 15: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 16: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 17: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 18: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 19: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 20: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 21: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 22: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 23: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 24: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 25: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 26: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 27: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 28: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 29: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 30: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 31: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 32: /Big/clang-15/FC31/bin/FC31clang-15-server(dai_auto_settler_run+0x49e2) [0x55eca4c0b482] 3: 33: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settlers_player+0x18d9) [0x55eca46d7929] 3: 34: /Big/clang-15/FC31/bin/FC31clang-15-server(+0x85f790) [0x55eca4620790] 3: 35: /Big/clang-15/FC31/bin/FC31clang-15-server(+0x85a335) [0x55eca461b335] 3: 36: /Big/clang-15/FC31/bin/FC31clang-15-server(srv_main+0x4a4) [0x55eca46158f4] 3: 37: /Big/clang-15/FC31/bin/FC31clang-15-server(main+0x2031) [0x55eca45fe851] 3: 38: /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f1feae29d90] 3: 39: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7f1feae29e40] 3: 40: /Big/clang-15/FC31/bin/FC31clang-15-server(_start+0x25) [0x55eca453cc35] Game saved as Sz1-Ai002-Lm59-230507_192610-T0056-auto.sav.xz
memo for debug
This part of code has not changed since 2015
$ git blame server/advisors/autosettlers.c 2dc87be216 server/advisors/autosettlers.c (Marko Lindqvist 2017-10-24 21:25:14 +0300 909) /**********************************************************************//** 30444180c6 server/settlers.c (Per I. Mathisen 2004-08-05 11:34:18 +0000 910) Find some work for our settlers and/or workers. f9d2488b21 server/settlers.c (Thue Janus Kristensen 2001-08-14 14:31:21 +0000 911) **************************************************************************/ 30444180c6 server/settlers.c (Per I. Mathisen 2004-08-05 11:34:18 +0000 912) #define LOG_SETTLER LOG_DEBUG 7516e073db server/advisors/autosettlers.c (Marko Lindqvist 2010-08-06 06:35:35 +0000 913) void auto_settler_findwork(struct player *pplayer, 7516e073db server/advisors/autosettlers.c (Marko Lindqvist 2010-08-06 06:35:35 +0000 914) struct unit *punit, 7516e073db server/advisors/autosettlers.c (Marko Lindqvist 2010-08-06 06:35:35 +0000 915) struct settlermap *state, 7516e073db server/advisors/autosettlers.c (Marko Lindqvist 2010-08-06 06:35:35 +0000 916) int recursion) f9d2488b21 server/settlers.c (Thue Janus Kristensen 2001-08-14 14:31:21 +0000 917) { f18fcf4f6a server/advisors/autosettlers.c (Marko Lindqvist 2015-05-07 00:40:22 +0000 918) struct worker_task *best_task; adcd30119f server/settlers.c (Jason Dorje Short 2004-08-17 05:13:59 +0000 919) enum unit_activity best_act; 18fa1c4a1e server/settlers.c (Mike Kaufman 2004-09-29 02:24:24 +0000 920) struct tile *best_tile = NULL; 65f576397a server/advisors/autosettlers.c (Marko Lindqvist 2013-07-10 16:49:07 +0000 921) struct extra_type *best_target; 85a632bfc7 server/settlers.c (Marko Lindqvist 2009-09-08 21:24:00 +0000 922) struct pf_path *path = NULL; d4d6357449 server/advisors/autosettlers.c (Marko Lindqvist 2015-01-24 20:01:21 +0000 923) struct city *taskcity; f9d2488b21 server/settlers.c (Thue Janus Kristensen 2001-08-14 14:31:21 +0000 924) b728d863b1 server/settlers.c (Jason Dorje Short 2005-05-04 08:10:07 +0000 925) /* time it will take worker to complete its given task */ b728d863b1 server/settlers.c (Jason Dorje Short 2005-05-04 08:10:07 +0000 926) int completion_time = 0; b728d863b1 server/settlers.c (Jason Dorje Short 2005-05-04 08:10:07 +0000 927) 11c78aed28 server/settlers.c (Jason Dorje Short 2005-06-16 19:54:06 +0000 928) if (recursion > unit_list_size(pplayer->units)) { 3ee7e07584 server/settlers.c (pepeto 2010-02-25 19:41:15 +0000 929) fc_assert(recursion <= unit_list_size(pplayer->units)); 8d6bef3f2b server/advisors/autosettlers.c (Marko Lindqvist 2011-01-21 00:16:41 +0000 930) adv_unit_new_task(punit, AUT_NONE, NULL); 11c78aed28 server/settlers.c (Jason Dorje Short 2005-06-16 19:54:06 +0000 931) set_unit_activity(punit, ACTIVITY_IDLE); 11c78aed28 server/settlers.c (Jason Dorje Short 2005-06-16 19:54:06 +0000 932) send_unit_info(NULL, punit); 11c78aed28 server/settlers.c (Jason Dorje Short 2005-06-16 19:54:06 +0000 933) return; /* avoid further recursion. */ 11c78aed28 server/settlers.c (Jason Dorje Short 2005-06-16 19:54:06 +0000 934) }
most of the file is unchanged
Only change in 2023 , elsewhere 5a099fdba2 : AI: Correct equality tests between float adv_want values (I don't think it is related , i may be wrong)
2dc87be216 server/advisors/autosettlers.c (Marko Lindqvist 2017-10-24 21:25:14 +0300 302) /**********************************************************************//** 85a632bfc7 server/settlers.c (Marko Lindqvist 2009-09-08 21:24:00 +0000 303) Compares the best known tile improvement action with improving ptile 85a632bfc7 server/settlers.c (Marko Lindqvist 2009-09-08 21:24:00 +0000 304) with activity act. Calculates the value of improving the tile by 85a632bfc7 server/settlers.c (Marko Lindqvist 2009-09-08 21:24:00 +0000 305) discounting the total value by the time it would take to do the work 3b58d31ce3 server/settlers.c (Jason Dorje Short 2004-02-26 03:24:16 +0000 306) and multiplying by some factor. 2dc87be216 server/advisors/autosettlers.c (Marko Lindqvist 2017-10-24 21:25:14 +0300 307) **************************************************************************/ 85a632bfc7 server/settlers.c (Marko Lindqvist 2009-09-08 21:24:00 +0000 308) static void consider_settler_action(const struct ... 5a099fdba2 server/advisors/autosettlers.c (Marko Lindqvist 2023-04-22 14:30:17 +0300 349) || (ADV_WANTS_EQ(new_tile_value, *best_value) 5a099fdba2 server/advisors/autosettlers.c (Marko Lindqvist 2023-04-22 14:30:17 +0300 350) && old_tile_value < *best_old_tile_value))) {
clang has optimized out all the variables (compiled with -g -O2)
Breakpoint 2, auto_settler_findwork (pplayer=<optimized out>, punit=<optimized out>, state=<optimized out>, recursion=<optimized out>) at ../../../server/advisors/autosettlers.c:917 917 { (gdb) ]]]
the backtrace show 14 calls to auto_settler_setup_work
3: 30: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_findwork+0x6f7) [0x55eca46d0c07] 3: 31: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settler_setup_work+0x1485) [0x55eca46d2cd5] 3: 32: /Big/clang-15/FC31/bin/FC31clang-15-server(dai_auto_settler_run+0x49e2) [0x55eca4c0b482] 3: 33: /Big/clang-15/FC31/bin/FC31clang-15-server(auto_settlers_player+0x18d9) [0x55eca46d7929] 3: 34: /Big/clang-15/FC31/bin/FC31clang-15-server(+0x85f790) [0x55eca4620790] 3: 35: /Big/clang-15/FC31/bin/FC31clang-15-server(+0x85a335) [0x55eca461b335] 3: 36: /Big/clang-15/FC31/bin/FC31clang-15-server(srv_main+0x4a4) [0x55eca46158f4]
The save files gives :
$ xzgrep -e "^\[player[0-9]*\]" -e nunits Sz1-Ai002-Lm59-230507_192610-T0055-auto.sav.xz [player0] nunits=13 [player1] nunits=23 [player2] nunits=3
For player0
u={"id","x","y","facing","nationality"," ... 167,13,31,"2",0,0,10,148,"Workers",4,20, ... 166,29,34,"6",0,0,10,124,"Workers",0,0,- ... 158,28,35,"3",0,0,10,124,"Workers",0,0,- ... 154,27,33,"8",0,0,10,124,"Workers",0,0,- ... 136,28,29,"7",0,0,10,124,"Workers",0,0,- ... 134,3,34,"8",0,0,10,124,"Workers",0,0,-1 ... 129,5,35,"6",0,0,10,124,"Workers",0,0,-1 ... 126,23,34,"2",0,0,10,124,"Workers",0,0,- ... 111,9,2,"2",0,0,10,0,"Explorer",0,0,-1,0 ... 110,20,35,"4",0,0,10,0,"Workers",0,0,-1, ... 109,5,20,"6",0,0,10,0,"Workers",0,0,-1,0 ... 108,19,35,"4",0,0,10,0,"Workers",0,0,-1, ... 105,28,31,"7",0,0,10,0,"Phalanx",5,0,-1, ... }
Likely overzealous assert. I don't see why it would be impossible to end up recursing more than number of units, as comments elsewhere already mention the possibility that recursion leads same unit getting activated again (unit activated by recursion activates the original unit by further recursion). Another possibility is that one of the units has died, so their count has gone down.
Yes, overzealous probably, even more if it is normal case. (and i hope unit count is refreshed when a unit die or we have another bug :-)
But i still try to understand/learn the ai part.
Breakpoint 2, auto_settler_findwork (pplayer=<optimized out>, punit=<optimized out>, state=<optimized out>, recursion=<optimized out>) at ../../../server/advisors/autosettlers.c:917 917 { (gdb) bt #0 auto_settler_findwork (pplayer=<optimized out>, punit=<optimized out>, state=<optimized out>, recursion=<optimized out>) at ../../../server/advisors/autosettlers.c:917 #1 0x0000555555e65cd5 in auto_settler_setup_work (pplayer=<optimized out>, punit=0x613000020800, state=<optimized out>, recursion=<optimized out>, path=<optimized out>, best_tile=<optimized out>, best_act=<optimized out>, best_target=<optimized out>, completion_time=<optimized out>) at ../../../server/advisors/autosettlers.c:1044 #2 0x000055555639e482 in dai_auto_settler_run (ait=<optimized out>, pplayer=<optimized out>, punit=<optimized out>, state=<optimized out>) at ../../../ai/default/daisettler.c:1165 #3 0x0000555555e6a929 in auto_settlers_player (pplayer=pplayer@entry=0x62100003d500) at ../../../server/advisors/autosettlers.c:1218 #4 0x0000555555db3790 in end_phase () at ../../server/srv_main.c:1434 #5 0x0000555555dae335 in srv_running () at ../../server/srv_main.c:2913 #6 0x0000555555da88f4 in srv_main () at ../../server/srv_main.c:3480 #7 0x0000555555d91851 in main (argc=<optimized out>, argv=<optimized out>) at ../../server/civserver.c:486 (gdb)
What surprises me currently is the need of recursion, as it seems we are already in a loop over all units.
In human order , the first call is settler_run , inside a unit_list_iterate_safe
Beginning of the function ../../../server/advisors/autosettlers.c:1142 /**********************************************************************//** Run through all the players settlers and let those on ai.control work automagically. **************************************************************************/ void auto_settlers_player(struct player *pplayer) { ... ../../../server/advisors/autosettlers.c:1188 unit_list_iterate_safe(pplayer->units, punit) { ... ../../../server/advisors/autosettlers.c:1218 <--- our call CALL_PLR_AI_FUNC(settler_run, pplayer, pplayer, punit, state); } } } } unit_list_iterate_safe_end;
./ai/classic/classicai.c:665: ai->funcs.settler_run = cai_auto_settler_run;
./ai/classic/classicai.c:411 /**********************************************************************//** Call default ai with classic ai type as parameter. **************************************************************************/ static void cai_auto_settler_run(struct player *pplayer, struct unit *punit, struct settlermap *state) { struct ai_type *deftype = classic_ai_get_self(); dai_auto_settler_run(deftype, pplayer, punit, state); }
ai/default/daisettler.c:1012: void dai_auto_settler_run( try different stuff (build city, do something asked for by a city , take a boat, build a city line:1165 if (best_tile != NULL && auto_settler_setup_work(pplayer, ... ) <--- first call && pcity != NULL) { clear_worker_tasks(pcity); }
../../../server/advisors/autosettlers.c : 991 /**********************************************************************//** Setup our settler to do the work it has found. Returns TRUE if started actual work. **************************************************************************/ bool auto_settler_setup_work(struct player *pplayer, struct unit *punit, ... /* Mark the square as taken. */ displaced = player_unit_by_number(pplayer, state[tile_index(best_tile)].enroute); ... line:1044 if (displaced) { .... auto_settler_findwork(pplayer, displaced, state, recursion + 1); <------ our line 1044, begins a recursion if (NULL == player_unit_by_number(pplayer, saved_id)) { /* Actions of the displaced settler somehow caused this settler * to die. (maybe by recursively giving control back to this unit) */ return FALSE; }
../../../server/advisors/autosettlers.c:909 /**********************************************************************//** Find some work for our settlers and/or workers. **************************************************************************/ #define LOG_SETTLER LOG_DEBUG void auto_settler_findwork(...) tasks asked for by cities line 955 : if (auto_settler_setup_work <---- recursion Last try to find something again line 970: if (unit_has_type_flag(punit, UTYF_SETTLERS)) { line 981: auto_settler_setup_work( <---- recursion }
I don't understand why there is a test against number of units. We are inside a safe_ iteration over all units at upper level, so here we just manage ONE unit.
Or does it mean we go only once here for each unit, and the test is a kind of watchdog (and recursion is remembered between calls) ?
Reply To alain_bkr
so here we just manage ONE unit.
The recursion at line 1044 calls it for another unit (one 'displaced' by the original)
Reply to cazfi
The recursion at line 1044 calls it for another unit (one 'displaced' by the original)
Ok
But, We have 26 workers and 27 calls to dai_auto_settler_run. (numbers of workers checked from saved files), (maybe one one was created and died during the turn, i'll check other games if needed)
The calling sequence from profile is :
0.00 0.23 1/1 srv_main [2] [5] 20.1 0.00 0.23 1 srv_running [5] 0.00 0.15 3/3 end_phase [12]
0.00 0.15 3/3 srv_running [5] [12] 13.3 0.00 0.15 3 end_phase [12]
0.00 0.09 3/3 end_phase [12] [21] 8.1 0.00 0.09 3 auto_settlers_player [21] 0.00 0.09 27/27 dai_auto_settler_run [23]
0.00 0.09 27/27 auto_settlers_player [21] [23] 7.9 0.00 0.09 27 dai_auto_settler_run [23] 0.00 0.05 27/27 auto_settler_setup_work <cycle 1> [101]
45 auto_settler_findwork <cycle 1> [49] 0.00 0.05 27/27 dai_auto_settler_run [23] [101] 0.9 0.00 0.01 72 auto_settler_setup_work <cycle 1> [101] ... 46 auto_settler_findwork <cycle 1> [49]
46 auto_settler_setup_work <cycle 1> [101] [49] 3.6 0.00 0.04 46 auto_settler_findwork <cycle 1> [49] 45 auto_settler_setup_work <cycle 1> [101]
This seems to be trivially reproducible from the savegame. I'll have a look.
3: recursion: 15, unit_list_size: 14
Total of units in saved game :
2 "Archers" 2 "Explorer" 3 "Legion" 3 "Phalanx" 3 "Settlers" 26 "Workers"
27 calls to dai_auto_settler_run
autosettlers.c:1146: void auto_settlers_player(struct player *pplayer) ... /* Auto-settle with a settler unit if ...*/ line 1188 unit_list_iterate_safe(pplayer->units, punit) { ... CALL_PLR_AI_FUNC(settler_run, pplayer, pplayer, punit, state); }
It seems that unit_list_iterate_safe(pplayer->units, punit) iterates once too often.
Frame 48 is the call with recursion level 0.
#3 0x0000555555809251 in fc_assert_fail ( file=file@entry=0x5555558572f0 "../../../src/server/advisors/autosettlers.c", function=function@entry=0x5555558579d0 <__FUNCTION__.8> "auto_settler_findwork", line=line@entry=929, assertion=assertion@entry=0x555555857528 "recursion <= unit_list_size(pplayer->units)", message=<optimized out>) at ../../src/utility/log.c:568 #4 0x00005555555d1383 in auto_settler_findwork (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x5555569665c0, state=state@entry=0x555556808d50, recursion=recursion@entry=15) at ../../../src/server/advisors/autosettlers.c:929 #5 0x00005555555d1642 in auto_settler_setup_work (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556965ee0, state=state@entry=0x555556808d50, recursion=recursion@entry=14, path=path@entry=0x555556575f90, best_tile=best_tile@entry=0x555556b29270, best_act=ACTIVITY_GEN_ROAD, best_target=0x7fffffffc040, completion_time=3) at ../../../src/server/advisors/autosettlers.c:1044 #6 0x00005555555d12a2 in auto_settler_setup_work (completion_time=3, best_target=0x7fffffffc040, best_act=<optimized out>, best_tile=0x555556b29270, path=0x555556575f90, recursion=14, state=0x555556808d50, punit=0x555556965ee0, pplayer=0x55555866b850) at ../../../src/server/advisors/autosettlers.c:1004 #7 auto_settler_findwork (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556965ee0, state=state@entry=0x555556808d50, recursion=recursion@entry=14) at ../../../src/server/advisors/autosettlers.c:981 #8 0x00005555555d1642 in auto_settler_setup_work (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556e72720, state=state@entry=0x555556808d50, recursion=recursion@entry=13, path=path@entry=0x55555656fdc0, best_tile=best_tile@entry=0x555556b2d410, best_act=ACTIVITY_MINE, best_target=0x7fffffffc240, completion_time=2) at ../../../src/server/advisors/autosettlers.c:1044 #9 0x00005555555d12a2 in auto_settler_setup_work (completion_time=2, best_target=0x7fffffffc240, best_act=<optimized out>, best_tile=0x555556b2d410, path=0x55555656fdc0, recursion=13, state=0x555556808d50, punit=0x555556e72720, pplayer=0x55555866b850) at ../../../src/server/advisors/autosettlers.c:1004 #10 auto_settler_findwork (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556e72720, state=state@entry=0x555556808d50, recursion=recursion@entry=13) at ../../../src/server/advisors/autosettlers.c:981 #11 0x00005555555d1642 in auto_settler_setup_work (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556966930, state=state@entry=0x555556808d50, recursion=recursion@entry=12, path=path@entry=0x55555656fda0, best_tile=best_tile@entry=0x555556b257d0, best_act=ACTIVITY_GEN_ROAD, best_target=0x7fffffffc440, completion_time=19) at ../../../src/server/advisors/autosettlers.c:1044 #12 0x00005555555d12a2 in auto_settler_setup_work (completion_time=19, best_target=0x7fffffffc440, best_act=<optimized out>, best_tile=0x555556b257d0, path=0x55555656fda0, recursion=12, state=0x555556808d50, punit=0x555556966930, pplayer=0x55555866b850) at ../../../src/server/advisors/autosettlers.c:1004 #13 auto_settler_findwork (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556966930, --Type <RET> for more, q to quit, c to continue without paging-- state=state@entry=0x555556808d50, recursion=recursion@entry=12) at ../../../src/server/advisors/autosettlers.c:981 #14 0x00005555555d1642 in auto_settler_setup_work (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556966ca0, state=state@entry=0x555556808d50, recursion=recursion@entry=11, path=path@entry=0x555557080350, best_tile=best_tile@entry=0x555556b28550, best_act=ACTIVITY_GEN_ROAD, best_target=0x7fffffffc640, completion_time=11) at ../../../src/server/advisors/autosettlers.c:1044 #15 0x00005555555d12a2 in auto_settler_setup_work (completion_time=11, best_target=0x7fffffffc640, best_act=<optimized out>, best_tile=0x555556b28550, path=0x555557080350, recursion=11, state=0x555556808d50, punit=0x555556966ca0, pplayer=0x55555866b850) at ../../../src/server/advisors/autosettlers.c:1004 #16 auto_settler_findwork (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556966ca0, state=state@entry=0x555556808d50, recursion=recursion@entry=11) at ../../../src/server/advisors/autosettlers.c:981 #17 0x00005555555d1642 in auto_settler_setup_work (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x5555569665c0, state=state@entry=0x555556808d50, recursion=recursion@entry=10, path=path@entry=0x555557080330, best_tile=best_tile@entry=0x555556b29270, best_act=ACTIVITY_GEN_ROAD, best_target=0x7fffffffc840, completion_time=8) at ../../../src/server/advisors/autosettlers.c:1044 #18 0x00005555555d12a2 in auto_settler_setup_work (completion_time=8, best_target=0x7fffffffc840, best_act=<optimized out>, best_tile=0x555556b29270, path=0x555557080330, recursion=10, state=0x555556808d50, punit=0x5555569665c0, pplayer=0x55555866b850) at ../../../src/server/advisors/autosettlers.c:1004 #19 auto_settler_findwork (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x5555569665c0, state=state@entry=0x555556808d50, recursion=recursion@entry=10) at ../../../src/server/advisors/autosettlers.c:981 #20 0x00005555555d1642 in auto_settler_setup_work (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556965ee0, state=state@entry=0x555556808d50, recursion=recursion@entry=9, path=path@entry=0x555556726c70, best_tile=best_tile@entry=0x555556b2d410, best_act=ACTIVITY_MINE, best_target=0x7fffffffca40, completion_time=3) at ../../../src/server/advisors/autosettlers.c:1044 #21 0x00005555555d12a2 in auto_settler_setup_work (completion_time=3, best_target=0x7fffffffca40, best_act=<optimized out>, best_tile=0x555556b2d410, path=0x555556726c70, recursion=9, state=0x555556808d50, punit=0x555556965ee0, pplayer=0x55555866b850) at ../../../src/server/advisors/autosettlers.c:1004 #22 auto_settler_findwork (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556965ee0, state=state@entry=0x555556808d50, recursion=recursion@entry=9) at ../../../src/server/advisors/autosettlers.c:981 #23 0x00005555555d1642 in auto_settler_setup_work (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556966250, state=state@entry=0x555556808d50, recursion=recursion@entry=8, path=path@entry=0x55555707f360, best_tile=best_tile@entry=0x555556b285c0, best_act=ACTIVITY_IRRIGATE, best_target=0x7fffffffcc40, completion_time=4) at ../../../src/server/advisors/autosettlers.c:1044 #24 0x00005555555d12a2 in auto_settler_setup_work (completion_time=4, best_target=0x7fffffffcc40, best_act=<optimized out>, best_tile=0x555556b285c0, path=0x55555707f360, recursion=8, state=0x555556808d50, punit=0x555556966250, pplayer=0x55555866b850) at ../../../src/server/advisors/autosettlers.c:1004 #25 auto_settler_findwork (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556966250, --Type <RET> for more, q to quit, c to continue without paging-- state=state@entry=0x555556808d50, recursion=recursion@entry=8) at ../../../src/server/advisors/autosettlers.c:981 #26 0x00005555555d1642 in auto_settler_setup_work (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556e723b0, state=state@entry=0x555556808d50, recursion=recursion@entry=7, path=path@entry=0x5555570806c0, best_tile=best_tile@entry=0x555556b2c760, best_act=ACTIVITY_GEN_ROAD, best_target=0x7fffffffce40, completion_time=2) at ../../../src/server/advisors/autosettlers.c:1044 #27 0x00005555555d12a2 in auto_settler_setup_work (completion_time=2, best_target=0x7fffffffce40, best_act=<optimized out>, best_tile=0x555556b2c760, path=0x5555570806c0, recursion=7, state=0x555556808d50, punit=0x555556e723b0, pplayer=0x55555866b850) at ../../../src/server/advisors/autosettlers.c:1004 #28 auto_settler_findwork (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556e723b0, state=state@entry=0x555556808d50, recursion=recursion@entry=7) at ../../../src/server/advisors/autosettlers.c:981 #29 0x00005555555d1642 in auto_settler_setup_work (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x5555569676b0, state=state@entry=0x555556808d50, recursion=recursion@entry=6, path=path@entry=0x555556cd4730, best_tile=best_tile@entry=0x555556b29970, best_act=ACTIVITY_IRRIGATE, best_target=0x7fffffffd040, completion_time=17) at ../../../src/server/advisors/autosettlers.c:1044 #30 0x00005555555d12a2 in auto_settler_setup_work (completion_time=17, best_target=0x7fffffffd040, best_act=<optimized out>, best_tile=0x555556b29970, path=0x555556cd4730, recursion=6, state=0x555556808d50, punit=0x5555569676b0, pplayer=0x55555866b850) at ../../../src/server/advisors/autosettlers.c:1004 #31 auto_settler_findwork (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x5555569676b0, state=state@entry=0x555556808d50, recursion=recursion@entry=6) at ../../../src/server/advisors/autosettlers.c:981 #32 0x00005555555d1642 in auto_settler_setup_work (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556966930, state=state@entry=0x555556808d50, recursion=recursion@entry=5, path=path@entry=0x555556a49220, best_tile=best_tile@entry=0x555556b28550, best_act=ACTIVITY_GEN_ROAD, best_target=0x7fffffffd240, completion_time=13) at ../../../src/server/advisors/autosettlers.c:1044 #33 0x00005555555d12a2 in auto_settler_setup_work (completion_time=13, best_target=0x7fffffffd240, best_act=<optimized out>, best_tile=0x555556b28550, path=0x555556a49220, recursion=5, state=0x555556808d50, punit=0x555556966930, pplayer=0x55555866b850) at ../../../src/server/advisors/autosettlers.c:1004 #34 auto_settler_findwork (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556966930, state=state@entry=0x555556808d50, recursion=recursion@entry=5) at ../../../src/server/advisors/autosettlers.c:981 #35 0x00005555555d1642 in auto_settler_setup_work (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556966ca0, state=state@entry=0x555556808d50, recursion=recursion@entry=4, path=path@entry=0x555556a49240, best_tile=best_tile@entry=0x555556b29270, best_act=ACTIVITY_GEN_ROAD, best_target=0x7fffffffd440, completion_time=10) at ../../../src/server/advisors/autosettlers.c:1044 #36 0x00005555555d12a2 in auto_settler_setup_work (completion_time=10, best_target=0x7fffffffd440, best_act=<optimized out>, best_tile=0x555556b29270, path=0x555556a49240, recursion=4, state=0x555556808d50, punit=0x555556966ca0, pplayer=0x55555866b850) at ../../../src/server/advisors/autosettlers.c:1004 #37 auto_settler_findwork (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556966ca0, --Type <RET> for more, q to quit, c to continue without paging-- state=state@entry=0x555556808d50, recursion=recursion@entry=4) at ../../../src/server/advisors/autosettlers.c:981 #38 0x00005555555d1642 in auto_settler_setup_work (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x5555569665c0, state=state@entry=0x555556808d50, recursion=recursion@entry=3, path=path@entry=0x555556a49260, best_tile=best_tile@entry=0x555556b2d410, best_act=ACTIVITY_MINE, best_target=0x7fffffffd640, completion_time=8) at ../../../src/server/advisors/autosettlers.c:1044 #39 0x00005555555d12a2 in auto_settler_setup_work (completion_time=8, best_target=0x7fffffffd640, best_act=<optimized out>, best_tile=0x555556b2d410, path=0x555556a49260, recursion=3, state=0x555556808d50, punit=0x5555569665c0, pplayer=0x55555866b850) at ../../../src/server/advisors/autosettlers.c:1004 #40 auto_settler_findwork (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x5555569665c0, state=state@entry=0x555556808d50, recursion=recursion@entry=3) at ../../../src/server/advisors/autosettlers.c:981 #41 0x00005555555d1642 in auto_settler_setup_work (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556965ee0, state=state@entry=0x555556808d50, recursion=recursion@entry=2, path=path@entry=0x555556a49280, best_tile=best_tile@entry=0x555556b285c0, best_act=ACTIVITY_IRRIGATE, best_target=0x7fffffffd840, completion_time=4) at ../../../src/server/advisors/autosettlers.c:1044 #42 0x00005555555d12a2 in auto_settler_setup_work (completion_time=4, best_target=0x7fffffffd840, best_act=<optimized out>, best_tile=0x555556b285c0, path=0x555556a49280, recursion=2, state=0x555556808d50, punit=0x555556965ee0, pplayer=0x55555866b850) at ../../../src/server/advisors/autosettlers.c:1004 #43 auto_settler_findwork (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556965ee0, state=state@entry=0x555556808d50, recursion=recursion@entry=2) at ../../../src/server/advisors/autosettlers.c:981 #44 0x00005555555d1642 in auto_settler_setup_work (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556967360, state=state@entry=0x555556808d50, recursion=recursion@entry=1, path=path@entry=0x555556966560, best_tile=best_tile@entry=0x555556b27210, best_act=ACTIVITY_GEN_ROAD, best_target=0x7fffffffda40, completion_time=15) at ../../../src/server/advisors/autosettlers.c:1044 #45 0x00005555555d12a2 in auto_settler_setup_work (completion_time=15, best_target=0x7fffffffda40, best_act=<optimized out>, best_tile=0x555556b27210, path=0x555556966560, recursion=1, state=0x555556808d50, punit=0x555556967360, pplayer=0x55555866b850) at ../../../src/server/advisors/autosettlers.c:1004 #46 auto_settler_findwork (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x555556967360, state=0x555556808d50, recursion=recursion@entry=1) at ../../../src/server/advisors/autosettlers.c:981 #47 0x00005555555d1642 in auto_settler_setup_work (pplayer=0x55555866b850, punit=0x5555569676b0, state=<optimized out>, recursion=0, path=0x555557080220, best_tile=0x555556b28550, best_act=ACTIVITY_GEN_ROAD, best_target=0x7fffffffdc80, completion_time=14) at ../../../src/server/advisors/autosettlers.c:1044 #48 0x00005555555d2b4e in auto_settler_setup_work (pplayer=pplayer@entry=0x55555866b850, punit=punit@entry=0x5555569676b0, state=state@entry=0x555556808d50, recursion=recursion@entry=0, path=<optimized out>, best_tile=<optimized out>, best_act=ACTIVITY_GEN_ROAD, best_target=0x7fffffffdc80, completion_time=14) at ../../../src/server/advisors/autosettlers.c:1120
This is NOT an infinite recursion (two units displacing each other), but relaxing the check allows things to proceed just fine -> would fix this by 1) relaxing the check, and 2) turning assert in to a log message.
1. How to activate the UNIT_LOG ?
2. Maybe we were lucky on this one.
I added printf too see what happens
Le joueur 'Blackbeard' a maintenant le niveau IA 'Facile'. > Iterate pplayer Thracian, punit 167 Iterate pplayer Thracian, punit 166 AI settler_run : pplayer Thracian, punit 166 Iterate pplayer Thracian, punit 158 AI settler_run : pplayer Thracian, punit 158 Iterate pplayer Thracian, punit 154 AI settler_run : pplayer Thracian, punit 154 saved_id 154, displaced_id 166 Iterate pplayer Thracian, punit 136 AI settler_run : pplayer Thracian, punit 136 Iterate pplayer Thracian, punit 134 AI settler_run : pplayer Thracian, punit 134 Iterate pplayer Thracian, punit 129 AI settler_run : pplayer Thracian, punit 129 Iterate pplayer Thracian, punit 126 AI settler_run : pplayer Thracian, punit 126 saved_id 126, displaced_id 129 Iterate pplayer Thracian, punit 111 Iterate pplayer Thracian, punit 110 AI settler_run : pplayer Thracian, punit 110 Iterate pplayer Thracian, punit 109 AI settler_run : pplayer Thracian, punit 109 saved_id 109, displaced_id 110 saved_id 110, displaced_id 154 saved_id 154, displaced_id 134 saved_id 134, displaced_id 126 saved_id 126, displaced_id 129 saved_id 129, displaced_id 109 <------- this is our starting unit, we may have a cycle => maybe this is a good test for end (and keep the current assert) saved_id 109, displaced_id 158 saved_id 158, displaced_id 154 saved_id 154, displaced_id 134 saved_id 134, displaced_id 126 saved_id 126, displaced_id 129 saved_id 129, displaced_id 166 <------- but no, 109 is not again here , instead we have a new 166 saved_id 166, displaced_id 136 saved_id 136, displaced_id 158 1: in auto_settler_findwork() [../../../server/advisors/autosettlers.c::929]: assertion 'recursion <= unit_list_size(pplayer->units)' failed. >
- New S3_0 version with log_normal() instead of log_warn() that does not exist on that branch.
Pushed to S3_0, and later. While doing that, realized that this one should go to S2_6 too -> not closing the ticket, but keeping open for S2_6 handling. Current S3_0 patch applies there.
Freeciv version 3.1.0-beta1+ (version bêta) (origin/S3_1 a37fd14dd HEAD afdfd4fbf (+10) )
I found this error in serv.log (run04_clang-15/loop.230507-100844.done/Sz1-Ai002-Lm59-230507_192610.done/serv.log)