[Freeciv-Dev] (PR#12857) another freeze in decrease_unit_hp_smooth
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12857 >
I was playing in 2.0 and the game froze. The unit was displayed
constantly but nothing else happened (and the windows didn't update).
When I killed the client:
#1 0x407cf28a in usleep () from /lib/tls/libc.so.6
#2 0x0809cb70 in usleep_since_timer_start (t=0x8679708, usec=8845)
at timing.c:432
#3 0x080822f3 in decrease_unit_hp_smooth (punit0=0x87d50b8, hp0=0,
punit1=0x89a1b78, hp1=6) at mapview_common.c:1893
#4 0x0808336f in handle_unit_combat_info (attacker_unit_id=675,
defender_unit_id=144317304, attacker_hp=0, defender_hp=6,
make_winner_veteran=false) at packhand.c:295
#5 0x080883b6 in client_handle_packet (type=4294966780, packet=0x8679708)
at packhand_gen.c:168
#6 0x0806ef94 in handle_packet_input (packet=0x864f7d8, type=51)
at civclient.c:372
#7 0x08072bb1 in input_from_server (fd=4) at clinet.c:341
(gdb) select 3
p punit0(gdb) p punit0->hp
$1 = 4
(gdb) p punit1->hp
$2 = -4874
(gdb) p hp1
$3 = 6
(gdb) p diff0
$4 = 4
(gdb) p diff1
$5 = -4875
Once the unit has fewer HP than it's supposed to end with, we end up in
a near-infinite loop. I don't think there's any overt bug in
decrease_unit_hp but if it's given invalid input then the loop will break.
This patch should avoid the problem and silently correct the problem.
It remains a question what could cause this sort of thing.
-jason
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.227
diff -u -r1.227 mapview_common.c
--- client/mapview_common.c 20 Apr 2005 16:44:53 -0000 1.227
+++ client/mapview_common.c 21 Apr 2005 01:18:19 -0000
@@ -1660,6 +1660,11 @@
set_units_in_combat(punit0, punit1);
+ /* Make sure we don't start out with fewer HP than we're supposed to
+ * end up with (which would cause the following loop to break). */
+ punit0->hp = MAX(punit0->hp, hp0);
+ punit1->hp = MAX(punit1->hp, hp1);
+
unqueue_mapview_updates(TRUE);
while (punit0->hp > hp0 || punit1->hp > hp1) {
const int diff0 = punit0->hp - hp0, diff1 = punit1->hp - hp1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#12857) another freeze in decrease_unit_hp_smooth,
Jason Short <=
|
|