Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11354) server crash
Home

[Freeciv-Dev] (PR#11354) server crash

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: ph.bayon@xxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#11354) server crash
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 7 Dec 2004 09:42:16 -0800
Reply-to: rt@xxxxxxxxxxx

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

> [ph.bayon@xxxxxxxxxxxxxxx - Sun Dec 05 20:12:38 2004]:
> 
> hello,
> 
> with the cvs-Dec-02 version, i have the crash:
> 
> Program received signal SIGFPE, Arithmetic exception.
> 0x120119d54 in ai_manage_explorer (punit=0x1208b8030) at
> aiexplorer.c:302
> 302   aiexplorer.c: No such file or directory.
>       in aiexplorer.c
> bt
> #0  0x120119d54 in ai_manage_explorer (punit=0x1208b8030) at
> aiexplorer.c:302
> #1  0x12011be98 in ai_manage_ferryboat (pplayer=0x1202ee980,
> punit=0x1208b8030)
>     at aiferry.c:865
> #2  0x120129f04 in ai_manage_unit (pplayer=0x1202ee980,
> punit=0x1208b8030)
>     at aiunit.c:2174
> #3  0x12012a184 in ai_manage_units (pplayer=0x1202ee980) at
> aiunit.c:2206
> 
> print most_desirable
> $1 = 8.34058127e-35
> 
> then i replace two float variables by double:
> most_desirable
> desirable
> 
> it works.

Good report.  I think this patch is a better fix though.

-jason

Index: ai/aiexplorer.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiexplorer.c,v
retrieving revision 1.5
diff -u -r1.5 aiexplorer.c
--- ai/aiexplorer.c     29 Sep 2004 02:24:18 -0000      1.5
+++ ai/aiexplorer.c     7 Dec 2004 17:40:15 -0000
@@ -299,7 +299,14 @@
        *   log(most_desirable/BEST_POSSIBLE_SCORE) > dist * log(DIST_FACTOR)
        *   log(most_desirable/BEST_POSSIBLE_SCORE)/log(DIST_FACTOR) > dist
        */
-      max_dist = log(most_desirable / BEST_POSSIBLE_SCORE) / log(DIST_FACTOR);
+      if (most_desirable / BEST_POSSIBLE_SCORE < DIST_FACTOR) {
+       /* Shortcut the log call.  This is faster and avoids a potential
+        * crash if most_desirable is too small. */
+       max_dist = 0;
+      } else {
+       max_dist = log(most_desirable / BEST_POSSIBLE_SCORE)
+         / log(DIST_FACTOR);
+      }
     }
 
     if (pos.total_MC > max_dist) {

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#11354) server crash, Jason Short <=