Project

General

Profile

Bug #661865

Attempt to send negative city food_stock when units starving

Added by Marko Lindqvist over 3 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Category:
General
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Sane city always has at least 0 food stock, and it's defined unsigned in the network protocol. However, food_stock can be temporarily negative at the server side before enough food consuming units get wiped. That wiping of units causes city info to be sent in the middle of that temporary situation, resulting in network protocol warning.

#0 raise (sig=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x00005555557cf607 in fc_assert_fail (
file=file@entry=0x555555892760 "../../../src/common/networking/dataio_raw.c",
function=function@entry=0x555555892cb0 <__FUNCTION__.18521> "dio_put_uint16_raw", line=line@entry=288,
assertion=assertion@entry=0x5555558927d8 "!((int) (extension ({ unsigned short int _v, __x = (unsigned short int) (x); if (_builtin_constant_p (_x)) __v = ((unsigned short int) ((((_x) >> 8) & 0xff) | (((__x) & 0xff) << 8))); else __a"...,
message=0x55555588d89a "nologmsg:%s") at ../../src/utility/log.c:564
#2 0x00005555557f5c91 in dio_put_uint16_raw (dout=dout@entry=0x7fffffffbdf0,
value=-1) at ../../../src/common/networking/dataio_raw.c:285
#3 0x000055555578ae48 in send_packet_city_info_100 (
pc=0x555555b25cc0 <connections>, packet=0x7fffffffcf10,
force_to_send=<optimized out>) at ../../src/common/packets_gen.c:11185
#4 0x00005555555eaa78 in broadcast_city_info (pcity=pcity@entry=0x555559891340)
at ../../src/server/citytools.c:2158
#5 0x00005555555ead2f in send_city_info (dest=dest@entry=0x0,
pcity=pcity@entry=0x555559891340) at ../../src/server/citytools.c:2233
#6 0x00005555555b60a2 in server_remove_unit_full (punit=0x0,
punit@entry=0x5555591900f0, transported=transported@entry=false,
reason=reason@entry=ULR_STARVED) at ../../src/server/unittools.c:1787
#7 0x00005555555ba9cd in wipe_unit_full (punit=punit@entry=0x5555591900f0,
transported=<optimized out>, reason=reason@entry=ULR_STARVED,
killer=killer@entry=0x0) at ../../src/server/unittools.c:1890
#8 0x00005555555bb095 in wipe_unit (punit=punit@entry=0x5555591900f0,
reason=reason@entry=ULR_STARVED, killer=killer@entry=0x0)
at ../../src/server/unittools.c:2004
#9 0x00005555555efb71 in upkeep_kill_unit (punit=punit@entry=0x5555591900f0,
outp=outp@entry=O_FOOD, wipe_reason=wipe_reason@entry=ULR_STARVED,
wipe_in_the_end=<optimized out>) at ../../src/server/cityturn.c:691
#10 0x00005555555f7c74 in city_populate (nationality=0x555556d79fa0,
pcity=<optimized out>) at ../../src/server/cityturn.c:1042

History

#1 Updated by Marko Lindqvist about 1 year ago

Attached patch avoids the error message by making food_stock signed value also in the network protocol. No capstr changes needed as bits travel the same in the wire.

#2 Updated by Marko Lindqvist about 1 year ago

  • Status changed from Resolved to Closed
  • Assignee set to Marko Lindqvist

Also available in: Atom PDF