Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2004:
[Freeciv-Dev] (PR#9353) A save game that crashes the server
Home

[Freeciv-Dev] (PR#9353) A save game that crashes the server

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: astals11@xxxxxxxx
Subject: [Freeciv-Dev] (PR#9353) A save game that crashes the server
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 12 Jul 2004 13:40:35 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9353 >

The crash is this:

#0  0x400b3721 in kill () from /usr/lib/debug/libc.so.6
#1  0x400b34c5 in *__GI_raise (sig=6)
    at ../linuxthreads/sysdeps/unix/sysv/linux/raise.c:32
#2  0x400b49e8 in *__GI_abort () at ../sysdeps/generic/abort.c:88
#3  0x400acb3f in *__GI___assert_fail (assertion=0x0, file=0x0, line=0,
    function=0x814f973 "server_set_worker_city") at assert.c:83
#4  0x08069829 in server_set_worker_city (pcity=0x814f973, city_x=2101,
    city_y=135591805) at citytools.c:2103
#5  0x0806a09a in apply_cmresult_to_city (pcity=0x89e14b0, cmr=0xbffff6a0)
    at cityturn.c:162
#6  0x0812e223 in ai_manage_taxes (pplayer=0x81d24dc) at aihand.c:191
#7  0x0812e84c in ai_do_last_activities (pplayer=0x81d24dc) at aihand.c:385
#8  0x0804ef78 in end_phase () at srv_main.c:532
#9  0x08050892 in main_loop () at srv_main.c:1468
#10 0x080509ce in srv_main () at srv_main.c:1545
#11 0x0804a63f in main (argc=1, argv=0xbffff864) at civserver.c:161

the AI is attempting to force a city to be happy but no valid citizen
configuration is found.  But the AI tries to implement the result
anyway.  It needs to instead have a fallback.  Per, this looks like your
bug.

This patch improves the error documentation and catching.

jason

Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.251
diff -u -r1.251 cityturn.c
--- server/cityturn.c   12 Jul 2004 03:03:28 -0000      1.251
+++ server/cityturn.c   12 Jul 2004 20:39:55 -0000
@@ -143,12 +143,19 @@
 }
 
 /**************************************************************************
-  Rearrange workers according to a cm_result struct.
+  Rearrange workers according to a cm_result struct.  The caller must make
+  sure that the result is valid.
 **************************************************************************/
 void apply_cmresult_to_city(struct city *pcity, struct cm_result *cmr)
 {
   int i;
 
+  /* The caller had better check this! */
+  if (!cmr->found_a_valid) {
+    assert(0);
+    return;
+  }
+
   /* Now apply results */
   city_map_checked_iterate(pcity->x, pcity->y, x, y, mapx, mapy) {
     if (pcity->city_map[x][y] == C_TILE_WORKER

[Prev in Thread] Current Thread [Next in Thread]