Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#9578) Re: civserver crashed: http://pubserver.freeciv.
Home

[Freeciv-Dev] (PR#9578) Re: civserver crashed: http://pubserver.freeciv.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9578) Re: civserver crashed: http://pubserver.freeciv.org/games/320101
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Sun, 1 Aug 2004 05:17:33 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9578 >

On Sat, 31 Jul 2004 freeciv@xxxxxxxxxxxxxxxxxxxxx wrote:
> Program terminated with signal 8, Arithmetic exception.
...
> #0  0x08074d70 in get_research (pplayer=0x813bcb8) at report.c:344
> 344       return (pplayer->score.techout * 100) /
> (total_bulbs_required(pplayer));

(gdb) p pplayer->research
$3 = {bulbs_researched = 0, techs_researched = 2, researching = 66,
  changed_from = -1, bulbs_researched_before = 0 ...

(gdb) p pplayer->research.inventions[66]
$5 = {state = TECH_KNOWN, required_techs = '\0' <repeats 24 times>,
  num_required_techs = 0, bulbs_required = 0}

Clearly something is amiss here, since we are researching a tech we
already know. And this is version 1.13.0 that generated this core, so the
underlying bug might even be gone. But in any case, I think we should be a
bit defensive here, and rewrite the function like this (ie add the MAX):

static int get_research(struct player *pplayer)
{
  return (pplayer->score.techout * 100)
         / MAX(total_bulbs_required(pplayer), 1);
}

After all, we do not get any closer to finding any underlying bugs when
the code cores at this point. It just annoys players.

  - Per




[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9578) Re: civserver crashed: http://pubserver.freeciv.org/games/320101, Per I. Mathisen <=