Complete.Org: Mailing Lists: Archives: freeciv-dev: April 1999:
Re: [Freeciv-Dev] Freeciv 1.8.0 spinlock
Home

Re: [Freeciv-Dev] Freeciv 1.8.0 spinlock

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: Re: [Freeciv-Dev] Freeciv 1.8.0 spinlock
From: John Goerzen <jgoerzen@xxxxxxxxxxxx>
Date: 30 Apr 1999 13:55:33 -0500

Essentially, it looks like failsafe is asking it to go through over 1
billion iterations of the loop.  Analysis below.

Keep in mind:
 1. "long int" is 64-bits on the Alpha

David Pfitzner <dwp@xxxxxxxxxxxxxx> writes:

> > This sequence will cause the server to lock eating CPU:

[chomp]

> > > create foo
> > > create bar
> > > set generator 2
> > > s

[chomp]

> I don't see this problem, neither with current cvs, nor with 
> release-1.8.0.   I get the next server prompt, and no significant
> cpu use.

OK, I compiled with debug info.  Here is what I see:
#0  0x12006d98c in myrand (size=30) at shared.c:303
#1  0x120024970 in fillisland (coast=1, bucket=0x1201a5b98,
warm0_weight=1, 
    warm1_weight=1, cold0_weight=1, cold1_weight=1, warm0=T_RIVER, 
    warm1=T_RIVER, cold0=T_RIVER, cold1=T_RIVER) at mapgen.c:994
#2  0x120026a2c in makeisland (islemass=356, starters=1) at
mapgen.c:1189
#3  0x120027224 in mapgenerator2 () at mapgen.c:1274
#4  0x120022ebc in map_fractal_generate () at mapgen.c:691
#5  0x120010b34 in main (argc=1, argv=0x11ffff598) at civserver.c:368

That is from the first time I interrupted it.  I then allowed it to
continue for a few seconds and interrupted it again.  Now I see:

#0  fillisland (coast=1, bucket=0x1201a5b98, warm0_weight=1,
warm1_weight=1,
    cold0_weight=1, cold1_weight=1, warm0=T_RIVER, warm1=T_RIVER,
    cold0=T_RIVER, cold1=T_RIVER) at mapgen.c:1001
#1  0x120026a2c in makeisland (islemass=356, starters=1) at
mapgen.c:1189
#2  0x120027224 in mapgenerator2 () at mapgen.c:1274
#3  0x120022ebc in map_fractal_generate () at mapgen.c:691
#4  0x120010b34 in main (argc=1, argv=0x11ffff598) at civserver.c:368

At this point, I killed and restarted the server after looking at the
code.  Now:

(gdb) frame 1
#1  0x120024970 in fillisland (coast=1, bucket=0x1201a5b98,
warm0_weight=1,
    warm1_weight=1, cold0_weight=1, cold1_weight=1, warm0=T_RIVER,
    warm1=T_RIVER, cold0=T_RIVER, cold1=T_RIVER) at mapgen.c:994
994         y = myrand(s - n) + n;
(gdb) print y
$1 = 39
(gdb) print failsafe
$2 = 1214831389
(gdb) print i
$3 = 4214700

So now I killed civerserver again, set a breakpoint at fillisland, and 
started it.  Before the first iteration of the loop, we have:

993       while (i && failsafe--) {
8: i = 4214898
7: *bucket = 4294967159
4: y = 0
3: x = 3120
2: failsafe = 994702162

Earlier, before modifying bucket, one sees:

984       *bucket -= i * capac;
10: capac = 1019
9: *bucket = 4294981154
8: i = 4214899
4: y = 0
3: x = 2880
2: failsafe = 356

More strangeness....

304         RandomState[iRandX] = newRand;
(gdb) s
306         return newRand % size;
(gdb) print size
$3 = 33
(gdb) print newRand
$4 = 184393772
(gdb) s

At this point, it spinlocked.  Highly strange, that.

Not only that, but for certain invocations, newRand is printed out
negatively (!).

306         return newRand % size;
(gdb) print RandomState[iRandX]
$8 = -899041811
(gdb) disp RandomState[iRandX]
11: RandomState[iRandX] = -899041811
(gdb) print newRand
$9 = -899041811
(gdb) print size
$10 = 25

Something highly fishy is going on here.

-- 
John Goerzen   Linux, Unix consulting & programming   jgoerzen@xxxxxxxxxxxx |
Developer, Debian GNU/Linux (Free powerful OS upgrade)       www.debian.org |
----------------------------------------------------------------------------+
The 190,317,310th prime number is 4,007,863,141.

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