Ticket #47662

./common/city.c integer overflow ... cannot be represented in type 'int'

Open Date: 2023-03-23 21:13 Last Update: 2023-04-25 21:37

Reporter:
Owner:
(None)
Type:
Status:
Open
Component:
MileStone:
(None)
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
None
File:
None

Details

3.0.6 clang

This one is a bit weird : the value are always (-1 billion + epsilon) * 100 , and show identical values in different random games

Count of errors :

      7 ../../common/city.c:2880:37: runtime error: signed integer overflow: -999999992 * 100 cannot be represented in type 'int'      ### ~ 50 max_int
      5 ../../common/city.c:2880:37: runtime error: signed integer overflow: -999999991 * 100 cannot be represented in type 'int'
      4 ../../common/city.c:2880:37: runtime error: signed integer overflow: -999999994 * 100 cannot be represented in type 'int'
      3 ../../common/city.c:2880:37: runtime error: signed integer overflow: -999999987 * 100 cannot be represented in type 'int'

      6 ../../common/city.c:2873:25: runtime error: signed integer overflow: -999999990 * 100 cannot be represented in type 'int'
      6 ../../common/city.c:2873:25: runtime error: signed integer overflow: -999999989 * 100 cannot be represented in type 'int'
      3 ../../common/city.c:2873:25: runtime error: signed integer overflow: -999999994 * 100 cannot be represented in type 'int'
      3 ../../common/city.c:2873:25: runtime error: signed integer overflow: -999999993 * 100 cannot be represented in type 'int'
      3 ../../common/city.c:2873:25: runtime error: signed integer overflow: -999999987 * 100 cannot be represented in type 'int'

      6 > ../../common/city.c:2866:21: runtime error: signed integer overflow: -999999992 * 100 cannot be represented in type 'int'
      3 > ../../common/city.c:2866:21: runtime error: signed integer overflow: -999999994 * 100 cannot be represented in type 'int'
      3 > ../../common/city.c:2866:21: runtime error: signed integer overflow: -999999991 * 100 cannot be represented in type 'int'
      3 > ../../common/city.c:2866:21: runtime error: signed integer overflow: -999999987 * 100 cannot be represented in type 'int'

I'll try to investigate a bit and provide saved games.

Ticket History (3/6 Histories)

2023-03-23 21:13 Updated by: alain_bkr
  • New Ticket "./common/city.c integer overflow ... cannot be represented in type 'int'" created
2023-04-12 13:35 Updated by: cazfi
Comment

Possibly related assert failure on a S3_1 (+ local patches) autogame:

in city_build_building() [../../src/server/cityturn.c::2412]: assertion 'pcity->surplus[O_SHIELD] >= 0' failed.

2023-04-13 02:56 Updated by: cazfi
Comment

Reply To cazfi

Possibly related assert failure on a S3_1 (+ local patches) autogame: {{{ in city_build_building() [../../src/server/cityturn.c::2412]: assertion 'pcity->surplusO_SHIELD >= 0' failed. }}}

I don't know *exact* reason of this, but seems to be related to the mess of what upkeep gets paid pack when unit gets removed from the game. I think gold upkeep is the only form of upkeep that actually gets paid back. But even when unit dies for lack of gold, it does not pay back shields or food. Additional complication is that unit dying for lack of shields does so by "Help Wonder" or "Disband Unit Recover Production" meaning that often city's negative shield stock still gets turned positive by that death (but not as much as it should).

2023-04-18 17:40 Updated by: cazfi
Comment

I'm now getting that assert failure quite regularly. Either it's recently introduced bug, or the other changes have made AI much more likely to proceed to a situation where it triggers it (in an autogame)

2023-04-24 04:36 Updated by: cazfi
  • Milestone Update from (None) to 3.0.8 (closed)
  • Priority Update from 5 - Medium to 6
Comment

Reply To cazfi

I'm now getting that assert failure quite regularly.

Frequently enough to consider this a regression blocking 3.0.8. ( #47779 )

2023-04-25 21:37 Updated by: cazfi
  • Milestone Update from 3.0.8 (closed) to (None)
  • Component Update from Server to General
  • Priority Update from 6 to 5 - Medium
Comment

The assert is unrelated to the original problem after all -> split to #47938

Attachment File List

No attachments

Edit

Please login to add comment to this ticket » Login