Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2004:
[Freeciv-Dev] Re: (PR#8722) Fatal bugs and annoyances (resent)
Home

[Freeciv-Dev] Re: (PR#8722) Fatal bugs and annoyances (resent)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: vasc@xxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#8722) Fatal bugs and annoyances (resent)
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Thu, 13 May 2004 02:18:50 -0700
Reply-to: rt@xxxxxxxxxxx

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

On Wed, May 12, 2004 at 03:12:44PM -0700, Vasco Alexandre da Silva Costa wrote:
> 
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=8722 >
> 
> To reproduce:
> B) When disconnecting and re-connecting a client (like after it died
> from the bug above), the server often dies with an assert, like
> "Assertion 'pc->phs.variant != (void *) 0' failed" or something. I don't
> remember it happening before ext conn dialog was commited.
> 
> Do this:
> 
> $ ./ser -f civgame+1200.sav.gz
> $ ./civ -n bar -a
> 
> Then on the server console:
> /start
> /take bar 2
> 
> And you get this lovely message:
> 
> 2: Lost connection: bar from localhost.localdomain (player 2).
> civserver: packets_gen.c:17847: send_packet_start_turn: Assertion
> `pc->phs.variant != ((void *)0)' failed.
> Aborted

With the attached debug-patch I get this:

> This is the server for Freeciv version 1.14.99-devel
> You can learn a lot about Freeciv at http://www.freeciv.org/
> 2: Loading rulesets
> 2: Now accepting new client connections.
> 
> For introductory help, type 'help'.
> > 
> 2: common_init 0x8169b60
> 2:   variant=0x87f77e0
...
> 2: Connection request from bar from localhost.localdomain
...
> > st
> Starting game.
...
> > take bar 2
> 2: take command: conn= 0x8169b60 bar from localhost.localdomain (player 2)
> 2:   variant=0x87f77e0
The variant is ok here.
...
> 2: write_socket_data 51041
We try to send all 51k game data to the client. This is caused by 
  send_packet_thaw_hint(pconn);
in take_command

> 2: trying to write 4096 limit=0
> 2: last message repeated 2 times
> 2: last message repeated 2 times (total 4 repeats)
> 2: last message repeated 4 times (total 8 repeats)
> 2: last message repeated 2 times (total 10 repeats)
> 2: problem 104 Connection reset by peer

The connection to the client is closed.

> 2: Lost connection: bar from localhost.localdomain (player 2).

Yup it is closed.

> 2: common_close 0x8169b60
> 2:   variant=(nil)

Yes close it. variant is now NULL.

> 2: start_turn: conn= 0x8169b60
> 2:   variant=(nil)

Now the 
    send_packet_start_turn(pconn);
is called after the thaw.

> civserver: packets_gen.c:17849: send_packet_start_turn: Assertion `pc->phs.var
ia
> nt != ((void *)0)' failed.

And generates a nice error.

> Abgebrochen (core dumped)

There are two problems:

1) The generated packet code has to cope with closed connections since
connections can be closed at almost any time. It would be to hard for
the common code to catch this and abort its execution. I will provide
a patch for this.

2) For no apparent reason the connection is closed by the client. Too
many data at once?

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "SIGDANGER - The System is likely to crash soon"

Index: common/connection.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/connection.c,v
retrieving revision 1.38
diff -u -u -r1.38 connection.c
--- common/connection.c 5 May 2004 20:39:16 -0000       1.38
+++ common/connection.c 13 May 2004 09:15:01 -0000
@@ -166,6 +166,8 @@
     }
   }
 
+  freelog(LOG_NORMAL,"write_socket_data %d",buf->ndata);
+
   for (start=0; buf->ndata-start>limit;) {
     fd_set writefs, exceptfs;
     struct timeval tv;
@@ -195,10 +197,11 @@
 
     if (FD_ISSET(pc->sock, &writefs)) {
       nblock=MIN(buf->ndata-start, MAX_LEN_PACKET);
-      freelog(LOG_DEBUG,"trying to write %d limit=%d",nblock,limit);
+      freelog(LOG_NORMAL,"trying to write %d limit=%d",nblock,limit);
       if((nput=my_writesocket(pc->sock, 
                              (const char *)buf->data+start, nblock)) == -1) {
 #ifdef NONBLOCKING_SOCKETS
+         freelog(LOG_NORMAL,"problem %d %s",errno,strerror(errno));
        if (errno == EWOULDBLOCK || errno == EAGAIN) {
          break;
        }
@@ -578,6 +581,7 @@
 **************************************************************************/
 void connection_common_init(struct connection *pconn)
 {
+    freelog(LOG_NORMAL,"common_init %p",pconn);
   pconn->established = FALSE;
   pconn->used = TRUE;
   pconn->last_write = 0;
@@ -587,6 +591,7 @@
 
   init_packet_hashs(pconn);
 
+  freelog(LOG_NORMAL,"  variant=%p",pconn->phs.variant);
 #ifdef USE_COMPRESSION
   pconn->compression.frozen_level = 0;
   pconn->compression.queued_packets = NULL;
@@ -599,6 +604,7 @@
 **************************************************************************/
 void connection_common_close(struct connection *pconn)
 {
+    freelog(LOG_NORMAL,"common_close %p",pconn);
   my_closesocket(pconn->sock);
   pconn->used = FALSE;
   pconn->established = FALSE;
@@ -611,6 +617,7 @@
 
   free_compression_queue(pconn);
   free_packet_hashes(pconn);
+  freelog(LOG_NORMAL,"  variant=%p",pconn->phs.variant);
 }
 
 /**************************************************************************
Index: common/packets_gen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets_gen.c,v
retrieving revision 1.25
diff -u -u -r1.25 packets_gen.c
--- common/packets_gen.c        11 May 2004 17:18:19 -0000      1.25
+++ common/packets_gen.c        13 May 2004 09:15:05 -0000
@@ -17844,6 +17844,8 @@
 
 int send_packet_start_turn(struct connection *pc)
 {
+  freelog(LOG_NORMAL,"start_turn: conn= %p",pc);
+  freelog(LOG_NORMAL,"  variant=%p",pc->phs.variant);
   assert(pc->phs.variant != NULL);
   if(!is_server) {
     freelog(LOG_ERROR, "Sending packet_start_turn from the client.");
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.315
diff -u -u -r1.315 stdinhand.c
--- server/stdinhand.c  24 Apr 2004 17:32:47 -0000      1.315
+++ server/stdinhand.c  13 May 2004 09:15:11 -0000
@@ -3937,6 +3937,8 @@
   }
 
   if (server_state == RUN_GAME_STATE) {
+      freelog(LOG_NORMAL,"take command: conn= %p %s",pconn, 
conn_description(pconn));
+      freelog(LOG_NORMAL,"  variant=%p",pconn->phs.variant);
     send_packet_freeze_hint(pconn);
     send_rulesets(&pconn->self);
     send_all_info(&pconn->self);

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