> hi guys
> 
> a core dump on freebsd, unfortunatly i have only the last few lines of the 
> output:
> 70922) (10,2801,40866676)
> HSEP: Reachable nodes (1-10 hops): 4 6 9 13 13 13 13 13 13 13
> HSEP: Reachable files (1-10 hops): 1473 1473 2311 4274 4274 4274 4274 4274 
> 4274 4274
> HSEP:   Reachable KiB (1-10 hops): 5016455 5016455 8387377 45883131 45883131 
> 45883131 45883131 45883131 45883131 45883131
> 
> ** ERROR **: file hsep.c: line 589 (hsep_sanity_check): assertion failed: 
> (connectiont[HSEP_IDX_NODES + 3] == 1)
> aborting...

Hi,

this seems to be a race condition. It happenend to me once yesterday,
too, but I couldn't reproduce it.

It happens if a node has been detected to be HSEP-capable but has not
yet been initialized for HSEP (which is done a little later). If a
HSEP message from another node arrives just then or another HSEP-node
connection is closed, the sanity check is called and the above
assertion will fail for the new connection.

The connection's HSEP data needs to be initialized as soon as the
CAN_HSEP attribute is set. Attached is a patch that fixes this issue.
I also added some debug output for faulty HSEP messages.

As this is a serious problem, it should be applied to CVS ASAP.

Thanks!


Greetings,
Thomas.
Index: hsep.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/hsep.c,v
retrieving revision 1.9
diff -u -r1.9 hsep.c
--- hsep.c      3 Mar 2004 18:38:44 -0000       1.9
+++ hsep.c      9 Mar 2004 09:12:52 -0000
@@ -157,8 +157,7 @@
 /*
  * hsep_connection_init
  *
- * Initializes the connection's HSEP data to zero and sends the first HSEP
- * message to the node. Node must support HSEP.
+ * Initializes the connection's HSEP data. Node must support HSEP.
  */
  
 void hsep_connection_init(struct gnutella_node *n)
@@ -185,8 +184,6 @@
        n->hsep_msgs_sent = 0;
        n->hsep_triples_sent = 0;
        n->hsep_last_sent = 0;
-
-       hsep_send_msg(n);
 }
 
 /*
@@ -295,14 +292,26 @@
        connectiont = (guint64 *) &n->hsep_table[1];
        
        if (length == 0)  /* error, at least 1 triple must be present */
+       {
+               printf("HSEP: Node %p sent empty message\n", n);
                return;
+       }
 
        if (length % 24)  /* error, # of triples not an integer */
+       {
+               printf("HSEP: Node %p sent broken message\n", n);
                return;
+       }
 
        /* get N_MAX of peer servent (other_n_max) */
        msgmax = length / 24;
 
+       if (NODE_IS_LEAF(n) && msgmax > 1)
+       {
+               printf("HSEP: Node %p is a leaf, but sent %u triples instead of 1\n", 
n, msgmax);
+               return;
+       }
+
        /* truncate if peer servent sent more triples than we need */
        if (msgmax > HSEP_N_MAX)
                max = HSEP_N_MAX;
@@ -329,10 +338,16 @@
        /* sanity check */
 
        if (*messaget != 1)  /* number of nodes for 1 hop must be 1 */
+       {
+               printf("HSEP: Node %p's message's #nodes for 1 hop is not 1", n);
                return;
+       }
 
        if (!hsep_check_monotony((hsep_triple *) messaget, max))
+       {
+               printf("HSEP: Node %p's message's monotony check failed", n);
                return;
+       }
 
        printf("HSEP: Received %d %s from node %p (msg #%u): ", max,
            max == 1 ? "triple" : "triples", n, n->hsep_msgs_received + 1);
Index: nodes.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/nodes.c,v
retrieving revision 1.322
diff -u -r1.322 nodes.c
--- nodes.c     25 Feb 2004 20:15:23 -0000      1.322
+++ nodes.c     9 Mar 2004 09:12:55 -0000
@@ -2460,11 +2460,6 @@
                }
        }
 
-       /* Initialize connection's HSEP data and send first HSEP message. */
-
-       if (n->attrs & NODE_A_CAN_HSEP)
-               hsep_connection_init(n);
-
        /*
         * If we're an Ultranode, we're going to monitor the queries sent by
         * our leaves and by our neighbours.
@@ -3738,7 +3733,11 @@
                header_get_feature("hsep", head, &major, &minor);
  
                if (major == HSEP_VERSION_MAJOR && minor == HSEP_VERSION_MINOR)
+               {
                        n->attrs |= NODE_A_CAN_HSEP;
+                       hsep_connection_init(n);
+                       /* first HSEP message will be sent on next hsep_timer() call */
+               }
        }
        
        /*

Reply via email to