Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2002:
[Freeciv-Dev] Re: [FreeCiv-Cvs] per: Fix a division by zero that happens
Home

[Freeciv-Dev] Re: [FreeCiv-Cvs] per: Fix a division by zero that happens

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Per I. Mathisen" <per@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [FreeCiv-Cvs] per: Fix a division by zero that happens if we reque...
From: Raimar Falke <rf13@xxxxxxxxxxxxxxxxx>
Date: Thu, 10 Oct 2002 06:40:58 -0700

On Thu, Oct 10, 2002 at 10:12:07AM +0000, Per I. Mathisen wrote:
> On Thu, 10 Oct 2002, Raimar Falke wrote:
> > > Fix a division by zero that happens if we request a score report while a
> > > player is researching a known tech.
> >
> > This fix is a band-aid and band-aids are bad. Even if a new release is
> > this near. Especially since the real fix is probability easy do to.
> 
> The "band-aid" removes the problem, and we shouldn't ship a release with
> such a problem.
> 
> Also, I am not sure it is a band-aid. What, in your eyes, would a "real
> fix" involve?

We have the following places where research.researching is set:

./client/packhand.c:1191:  pplayer->research.researching=pinfo->researching;
./server/savegame.c:614:  plr->research.researching=secfile_lookup_int(file, 
./server/plrhand.c:1591:  cplayer->research.researching = 
pplayer->research.researching;

these are no problem

./server/plrhand.c:446:    plr->research.researching=sub_goal;

choose_goal_tech. If choose_goal_tech returns TRUE the condition
(get_invention(plr, plr->research.researching) == TECH_REACHABLE) will hold.

./server/plrhand.c:469:    plr->research.researching = A_NONE;
./server/plrhand.c:482:  plr->research.researching = i;

both in choose_random_tech. Either it is a future tech (A_NONE) or the
condition will hold.

./server/plrhand.c:508:  plr->research.researching=tech;

choose_tech. Condition also is always true.

./server/unittools.c:2351:  pplayer->research.researching = res_ing;

No problem since found_new_tech is called later.

So IMHO the core dump shouldn't happen. That isn't the expected
result. Attached is a patch which:
 - adds some asserts
 - makes choose_goal_tech static
 - formatting
 - s/int/bool/
 - some docu

It does _not_ change any semantic. But it should help to track down
any further issues. Please apply (at least the asserts).

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx

Attachment: tech_dev_by_zero1.diff
Description: Text document


[Prev in Thread] Current Thread [Next in Thread]