Incidencia #47747

AI: Danger overflows at military_advisor_choose_build()

Abrir Fecha: 2023-04-02 15:42 Última actualización: 2023-04-10 08:10

Informador:
Propietario:
(Ninguno)
Tipo:
Estado:
Open
Componente:
Hito:
(Ninguno)
Prioridad:
5 - Medium
Gravedad:
5 - Medium
Resolución:
Ninguno
Fichero:
Ninguno

Details

From https://osdn.net/projects/freeciv/ticket/46286#comment:12505:46286:1679918727 reported by alain_bkr:

30 ../../../ai/default/daimilitary.c:1784:20: runtime error: signed integer overflow
3 ../../../ai/default/daimilitary.c:1787:22: runtime error: signed integer overflow

This is with S3_1. Later branches have changed things around there, so this isn't necessarily relevant for them.

Ticket History (3/4 Histories)

2023-04-02 15:42 Updated by: cazfi
  • New Ticket "AI: Danger overflows at military_advisor_choose_build()" created
2023-04-10 01:56 Updated by: alain_bkr
Comentario

S3_1 , d7b47462748ff2e3c0d

I have applied patches form parent ticket #46286 0002-AI-Make-kill_desire-to-handle-want-as-adv_want.patch(8KB) S3_1

I still have this overflow (which i did not mention the first time, as it appeared later)

../../../ai/default/daimilitary.c:1793:20: runtime error: signed integer overflow

2023-04-10 02:20 Updated by: cazfi
Comentario

Reply To alain_bkr

S3_1 , d7b47462748ff2e3c0d I have applied patches form parent ticket #46286 0002-AI-Make-kill_desire-to-handle-want-as-adv_want.patch(8KB) S3_1 I still have this overflow (which i did not mention the first time, as it appeared later)

../../../ai/default/daimilitary.c:1793:20: runtime error: signed integer overflow

I think it's the same, with some lines added by the patches that have gone in.

(Edited, 2023-04-10 02:21 Updated by: cazfi)
2023-04-10 08:10 Updated by: alain_bkr
Comentario

ok .

I am a bit puzzled by these overflows.

This one is a percentage

   /* First determine the danger. It is measured in percents of our
       * defensive strength, capped at 200 + urgency */
      if (qdanger >= our_def) {
        if (urgency == 0) {
          /* Don't waste money */
          danger = 100;
        } else if (our_def == 0) {
          danger = 200 + urgency;
        } else {
          danger = MIN(200, 100 * qdanger / our_def) + urgency;
        }

overflow means qdanger > 200 millions , (or urgency > 2 billions )

i wonder how this can happen, and if it is not just the tip of the iceberg.

Attachment File List

No attachments

Editar

Please login to add comment to this ticket » Entrar