Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2002:
[Freeciv-Dev] Re: CMA assertion
Home

[Freeciv-Dev] Re: CMA assertion

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: CMA assertion
From: swamp-dog@xxxxxxxxxxxx (Guy Harrison)
Date: Sun, 09 Jun 2002 19:22:46 GMT

On Sun, 9 Jun 2002 10:47:48 +0200, Raimar Falke <rf13@xxxxxxxxxxxxxxxxx>
wrote:

>On Sat, Jun 08, 2002 at 09:48:11PM +0000, Guy Harrison wrote:
>
>[ Even after reading it three times I'm not sure that I understood
>everything. ]

It would have been clearer had I been able to reproduce the bug as
expected. The issue has crystalised in my mind. Everything below is a
consequence of one key point: at the point prior to failure, did the CMA
make the correct decision?

>> Hi Folks,
>> 
>> You may want to skip to the end of this email then come back. Saves you
>> wasting your time if this problem is known.
>> 
>> CVS 1.12.3-devel GTK CygWin/XFree86 FreeCiv
>> 
>> cma_core.c 1783
>> 
>> Machine "SD" [IP=192.168.0.1] (NT4 WKS SP6a) running one human civclient
>> and civserver. Machine "HH" [IP=192.168.0.16] (NT4 SVR SP6a) running one
>> human civclient and connected to civserver on SD. Six AI players.
>> 
>> This was reproducable at the time. Symptoms were that client on HH quit
>> unexpectedly triggered by the CMA assertion at line 1782 above.
>> Moreover, the client on HH could not reconnect: the moment it did so,
>> the same assertion triggered again.
>> 
>> Spurious (very infrequent) quitting of the clients has occurred before,
>> the CMA always gets a mention but I cannot verify if those were down to
>> the same assertion or not. 
>
>> Clients (one but never both at the same time to date) have quit with
>> both of us playing and when one person plays with their own local
>> civserver - therefore I doubt any of the network and machine info
>> above is relevent - I only mention it in case someone knows better.
>
>Network may only be an issue because of the latencies. See thread
>about "(PR#1546)".
>
>> To put it in a nutshell: CMA issues mentioned in this
>> paragraph "went away" when the client reconnected thus the game could be
>> continued. Obviously HH could not continue(*).
>> 
>> I just recreated the situation. Same machines, same connection, same
>> users (ie same .civclientrc), same server running the same "faulty" game
>> I saved at the time that the HH client assertion was reproducable. No
>> problems at all - to the extent that the two CMA controlled cities that
>> were being 'detached from' at the time of the failure, are still
>> controlled by the CMA even after a couple of turns by both clients.
>> 
>> (*) HH could continue. HH went to make a cup of tea and some toast ;-)
>> Meantime I hacked out the assertion from handle_city() in cma_core.c,
>> look for /*~~~*/ below. 
>
>> I half expected something horrible to happen as a result of this
>
>That is the correct attitude ;)
>
>> but HH got connected and the game was completed.
>
>Yes this assert is there so that people report bugs back.
>
>> <snip>
>> static void handle_city(struct city *pcity)
>> {
>>   struct cma_parameter parameter;
>>   struct cma_result result;
>>   size_t len;
>>   bool handled;
>>   int i;
>> 
>>   len = attr_city_get(ATTR_CITY_CMA_PARAMETER, pcity->id,
>>                    sizeof(parameter), &parameter);
>> 
>>   if (len == 0) {
>>     return;
>>   }
>> 
>>   freelog(HANDLE_CITY_LOG_LEVEL,
>>        "handle_city(city='%s'(%d) pos=(%d,%d) owner=%s)",
>> pcity->name,
>>        pcity->id, pcity->x, pcity->y, city_owner(pcity)->name);
>> 
>>   if (city_owner(pcity) != game.player_ptr) {
>>     cma_release_city(pcity);
>>     create_event(pcity->x, pcity->y, E_CITY_CMA_RELEASE,
>>               _("CMA: You lost control of %s. Detaching from city."),
>>               pcity->name);
>>     return;
>>   }
>> 
>>   assert(len == sizeof(parameter));
>> 
>>   freelog(HANDLE_CITY_LOG_LEVEL2, "START handle city='%s'(%d)",
>>        pcity->name, pcity->id);
>> 
>>   handled = FALSE;
>>   for (i = 0; i < 5; i++) {
>>     freelog(HANDLE_CITY_LOG_LEVEL2, "  try %d", i);
>> 
>>     cma_query_result(pcity, &parameter, &result);
>>     if (!result.found_a_valid) {
>>       freelog(HANDLE_CITY_LOG_LEVEL2, "  no valid found result");
>> 
>>       cma_release_city(pcity);
>> 
>>       create_event(pcity->x, pcity->y, E_CITY_CMA_RELEASE,
>>                 _("CMA: The agent can't fulfill the requirements "
>>                   "for %s. Passing back control."), pcity->name);
>>       handled = TRUE;
>>       break;
>>     } else {
>>       if (!apply_result_on_server(pcity, &result)) {
>>      freelog(HANDLE_CITY_LOG_LEVEL2, "  doesn't cleanly apply");
>>      if (i == 0) {
>>        create_event(pcity->x, pcity->y, E_NOEVENT,
>>                     _("CMA: %s has changed and the calculated "
>>                       "result can't be applied. Will retry."),
>>                     pcity->name);
>>      }
>>       } else {
>>      freelog(HANDLE_CITY_LOG_LEVEL2, "  ok");
>>      /* Everything ok */
>>      handled = TRUE;
>>      break;
>>       }
>>     }
>>   }
>> 
>>   if (!handled) {
>>     freelog(HANDLE_CITY_LOG_LEVEL2, "  not handled");
>> 
>>     create_event(pcity->x, pcity->y, E_CITY_CMA_RELEASE,
>>               _("CMA: %s has changed multiple times. This may be "
>>                 "an error in freeciv or bad luck. Please contact "
>>                 "<freeciv-dev@xxxxxxxxxxx>. The CMA will detach "
>>                 "itself from the city now."), pcity->name);
>> 
>>     cma_release_city(pcity);
>> /*~~~*/
>>      #if 0
>> #if (IS_DEVEL_VERSION || IS_BETA_VERSION)
>>     freelog(LOG_ERROR, _("CMA: %s has changed multiple times. This may
>> be "
>>                       "an error in freeciv or bad luck. Please
>> contact "
>>                       "<freeciv-dev@xxxxxxxxxxx>. The CMA will detach
>> "
>>                       "itself from the city now."), pcity->name);
>>     assert(0);
>>     exit(EXIT_FAILURE);
>> #endif
>>      #else
>>      #warning "FIXME: Hacked around DEVEL assertion"
>>      #endif
>> /*~~~*/
>>   }
>> 
>>   freelog(HANDLE_CITY_LOG_LEVEL2, "END handle city='%s'(%d)",
>> pcity->name,
>>        pcity->id);
>> }
>> </snip>
>> 
>> 
>> The difference between "irreproducable" but identical situation *now*
>> and reproducable but identical situation *then*? civserver looks likely.
>> 
>> Atm civserver's freshly loaded and "clean". Back then I left it running
>> even whilst I hacked the assertion out of both clients: I did *not* quit
>> civserver and reload the game.
>> 
>> The fact that HH couldn't stay connected is possibly a side-issue. I'm
>> not familiar with the FreeCiv sources but would it be unreasonable to
>> assume the assertion knobbled the client in such a way that not all CMA
>> controlled cities were detached? Until I recreated the situation today I
>> thought that this was the bug I was reporting - not too dramatic because
>> it wouldn't quit the client in a release version. The difference in CMA
>> behaviour imposed upon HH is obviously more important. Has Mr Leaky
>> visited the CMA code perhaps? ;-)
>> 
>> I didn't consider posting the saved game would be worthwhile. I'll hang
>> on to it for a few days just in case.
>> 
>> Thanks for all the effort you guys must be putting in developing this
>> game. Very impressive!
>
>Since I couldn't digest this out of your email: Can you reproduce the
>problem?

No. It was reproducable at the time. Not now.

HH -> connect
HH -> assertion
[repeat above a few times - 100% reproducable]

civserver told to save game *but* civserver is kept running.

Quit other (SD) client.
Recompile both clients with assertion removed.
SD -> connect
HH -> connect
HH -> assertion text as a message
HH manually turns off CMA for all cities
[turn done]
Game continues.


Yesterday when I recreated the situation (same machines, "users" etc).
Not reproducable. Additionally, the CMA remained in control without
complaint.

> - always: please send the savegame and instructions how to cause the problem
> - sometimes: speculate what may have caused it

Some difference between data held by a running civserver and data held
by "civserver -f [file]". Not very useful but it is about all I can say
with any degree of certainty.

> - no: this is bad since I have nothing I can work with

I appreciate that. I'll go digest the info on the website then delve
into the code. If I can isolate that CMA decision prior to failure we'll
have something concrete.


-- 
swamp-dog@xxxxxxxxxxxx


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