Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2004:
[Freeciv-Dev] Re: (PR#8552) civserver crash
Home

[Freeciv-Dev] Re: (PR#8552) civserver crash

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#8552) civserver crash
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 21 Apr 2004 08:08:23 -0700
Reply-to: rt@xxxxxxxxxxx

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

Jason Short wrote:

> so the error seems to be an unsafe unit iteration.  This bug is almost a 
> year old.  Can we have safe genlists yet?

And here's another one.

When the unit list iterators were last changed I did an audit of all 
callers of wipe_unit.  Obviously this wasn't sufficient.  There are 
probably more bugs out there.  I'm strongly in favor of implementing 
safe genlists.

jason

? cma_weirdness
? client/gui-qpe
? data/civ3
? data/womoks
Index: ai/aicity.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v
retrieving revision 1.149
diff -u -r1.149 aicity.c
--- ai/aicity.c 25 Feb 2004 20:23:49 -0000      1.149
+++ ai/aicity.c 21 Apr 2004 15:06:04 -0000
@@ -360,7 +360,7 @@
    * learn how to ferry explorers to new land. */
   city_list_iterate(pplayer->cities, pcity) {
     struct tile *ptile = map_get_tile(pcity->x, pcity->y);
-    unit_list_iterate(ptile->units, punit) {
+    unit_list_iterate_safe(ptile->units, punit) {
       if (unit_has_role(punit->type, L_EXPLORER)
           && pcity->id == punit->homecity
           && pcity->ai.urgency == 0) {
@@ -368,7 +368,7 @@
                  unit_name(punit->type));
        handle_unit_disband(pplayer,punit->id);
       }
-    } unit_list_iterate_end;
+    } unit_list_iterate_safe_end;
   } city_list_iterate_end;
   
   do {
@@ -683,7 +683,7 @@
     goto cleanup;
   }
 
-  unit_list_iterate(pcity->units_supported, punit) {
+  unit_list_iterate_safe(pcity->units_supported, punit) {
     if (city_unhappy(pcity)
         && punit->unhappiness != 0
         && punit->ai.passenger == 0) {
@@ -691,7 +691,7 @@
       handle_unit_disband(pplayer, punit->id);
       city_refresh(pcity);
     }
-  } unit_list_iterate_end;
+  } unit_list_iterate_safe_end;
 
   if (CITY_EMERGENCY(pcity)) {
     freelog(LOG_EMERGENCY, "Emergency in %s remains unresolved", 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: (PR#8552) civserver crash, Jason Short <=