View Issue Details

IDProjectCategoryView StatusLast Update
0002189GNUnettransport servicepublic2024-05-03 13:59
ReporterLRN Assigned ToMatthias Wachs  
PrioritynormalSeveritycrashReproducibilitysometimes
Status closedResolutionfixed 
Product VersionGit master 
Target Version0.9.3Fixed in Version0.9.3 
Summary0002189: Assertion failure in plugin_transport_tcp.c:904
Descriptionr20142+9
Steps To ReproduceRun a GNUnet node. Eventually (in less than 5 minutes) it will happen.
Additional Information
Attaching to process 14924
Reading symbols from d:\progs\gnunet\bin\gnunet-service-transport.exe...done.
Program received signal SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 14924.0x3980]
0x75c7280d in KERNELBASE!DeleteAce () from C:\Windows\syswow64\KernelBase.dll
(gdb) bt
#0  0x75c7280d in KERNELBASE!DeleteAce () from C:\Windows\syswow64\KernelBase.dll
#1  0x61c065a4 in GNUNET_abort () at common_logging.c:271
#2  0x6c383b9d in _fu128__skip_log () at plugin_transport_tcp.c:904
#3  0x00411b2d in _fu680__skip_log () at gnunet-service-transport_validation.c:489
#4  0x00404977 in _fu140__skip_log () at gnunet-service-transport_blacklist.c:775
#5  0x00411f09 in revalidate_address (cls=0x1dff440, tc=0x28fc90) at gnunet-service-transport_validation.c:568
#6  0x61c37675 in run_ready (rs=0x2c7f0, ws=0x2d808) at scheduler.c:682
#7  0x61c37de6 in GNUNET_SCHEDULER_run (task=0x61c426f6 <service_task>, task_cls=0x28fe28) at scheduler.c:870
#8  0x61c433da in GNUNET_SERVICE_run (argc=3, argv=0x1ddbea8, serviceName=0x4162d7 "transport", opt=GNUNET_SERVICE_OPTION_NONE, task=0x40244a <run>, task_cls=0x0) at service.c:1716
#9  0x004027c7 in main (argc=3, argv=0x1ddbea8) at gnunet-service-transport.c:629
(gdb) up 2
#2  0x6c383b9d in _fu128__skip_log () at plugin_transport_tcp.c:904
904       GNUNET_assert (session->client != NULL);
(gdb) p/x *session
$1 = {header = {pong_signature = {sig = {0x0 <repeats 256 times>}}, pong_sig_expires = {abs_value = 0x0}}, next = 0x0, plugin = 0x1dec928, client = 0x0, pending_messages_head = 0x1de5788, pending_messages_tail = 0x1de5788,
  transmit_handle = 0x0, target = {hashPubKey = {bits = {0x1c8bb058, 0xc7301a70, 0x8803e219, 0x6fc5ba36, 0x29b085e, 0x8c84eea8, 0x61c4838f, 0xa6977171, 0xb2891ccc, 0x84e34bab, 0x8d06ed05, 0x4ae1a785, 0x47ef32bf,
        0xbf6b1748, 0xda5ba853, 0x11aa9a2a}}}, receive_delay_task = 0x0, addr = 0x0, addrlen = 0x0, last_activity = {abs_value = 0x135c92f3ec3}, expecting_welcome = 0x1, inbound = 0x0, is_nat = 0x1,
  ats_address_network_type = 0x3000000}
(gdb) l
899       struct Plugin * plugin = cls;
900       struct PendingMessage *pm;
901
902       GNUNET_assert (plugin != NULL);
903       GNUNET_assert (session != NULL);
904       GNUNET_assert (session->client != NULL);
905
906       GNUNET_SERVER_client_set_timeout (session->client,
907                                         GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
908       GNUNET_STATISTICS_update (plugin->env->stats,
(gdb) up
#3  0x00411b2d in _fu680__skip_log () at gnunet-service-transport_validation.c:489
489             ret = papi->send (papi->cls, session,
TagsNo tags attached.
Attached Files
0001-Try-to-not-to-create-dead-end-NAT-sessions.patch (4,609 bytes)   
From b0a0aeac28295e7de9b427d621803ad6a3a2d76f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1=D1?=
 =?UTF-8?q?=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= <lrn1986@gmail.com>
Date: Wed, 29 Feb 2012 18:39:09 +0400
Subject: [PATCH] Try to not to create dead-end NAT sessions

---
 src/include/gnunet_nat_lib.h         |    4 +++-
 src/nat/nat.c                        |   13 ++++++++-----
 src/transport/plugin_transport_tcp.c |   19 ++++++++++++++++---
 3 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/src/include/gnunet_nat_lib.h b/src/include/gnunet_nat_lib.h
index 6c1db80..a46b453 100644
--- a/src/include/gnunet_nat_lib.h
+++ b/src/include/gnunet_nat_lib.h
@@ -117,8 +117,10 @@ GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *h, const void *addr,
  *
  * @param h handle (used for configuration)
  * @param sa the address of the peer (IPv4-only)
+ * @return GNUNET_SYSERR on error, GNUNET_NO if nat client is disabled,
+ *         GNUNET_OK otherwise
  */
-void
+int
 GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h,
                        const struct sockaddr_in *sa);
 
diff --git a/src/nat/nat.c b/src/nat/nat.c
index 5117f5d..3e5c4c1 100644
--- a/src/nat/nat.c
+++ b/src/nat/nat.c
@@ -1310,8 +1310,10 @@ GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h)
  *
  * @param h NAT handle for us (largely used for configuration)
  * @param sa the address of the peer (IPv4-only)
+ * @return GNUNET_SYSERR on error, GNUNET_NO if nat client is disabled,
+ *         GNUNET_OK otherwise
  */
-void
+int
 GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h,
                        const struct sockaddr_in *sa)
 {
@@ -1320,20 +1322,20 @@ GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h,
   struct GNUNET_OS_Process *proc;
 
   if (GNUNET_YES != h->enable_nat_client)
-    return;                     /* not permitted / possible */
+    return GNUNET_NO;                     /* not permitted / possible */
 
   if (h->internal_address == NULL)
   {
     LOG (GNUNET_ERROR_TYPE_WARNING, "nat",
          _
          ("Internal IP address not known, cannot use ICMP NAT traversal method\n"));
-    return;
+    return GNUNET_SYSERR;
   }
   GNUNET_assert (sa->sin_family == AF_INET);
   if (NULL == inet_ntop (AF_INET, &sa->sin_addr, inet4, INET_ADDRSTRLEN))
   {
     GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_WARNING, "nat", "inet_ntop");
-    return;
+    return GNUNET_SYSERR;
   }
   GNUNET_snprintf (port_as_string, sizeof (port_as_string), "%d", h->adv_port);
 #if DEBUG_NAT
@@ -1347,11 +1349,12 @@ GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h,
                                "gnunet-helper-nat-client", h->internal_address,
                                inet4, port_as_string, NULL);
   if (NULL == proc)
-    return;
+    return GNUNET_SYSERR;
   /* we know that the gnunet-helper-nat-client will terminate virtually
    * instantly */
   GNUNET_OS_process_wait (proc);
   GNUNET_OS_process_close (proc);
+  return GNUNET_OK;
 }
 
 
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index 2b2d728..1477137 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -1129,8 +1129,21 @@ tcp_plugin_get_session (void *cls,
                      "Created NAT WAIT connection to `%4s' at `%s'\n",
                      GNUNET_i2s (&session->target), GNUNET_a2s (sb, sbs));
 #endif
-    GNUNET_NAT_run_client (plugin->nat, &a4);
-    return session;
+    if (GNUNET_OK == GNUNET_NAT_run_client (plugin->nat, &a4))
+      return session;
+    else
+    {
+      /* This is necessary for disconnect_session() to work */
+      GNUNET_CONTAINER_multihashmap_put(plugin->sessionmap, &address->peer.hashPubKey, session, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+      session->addr = GNUNET_malloc (addrlen);
+      memcpy (session->addr, address->address, addrlen);
+      session->addrlen = addrlen;
+
+      GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (
+          plugin->nat_wait_conns, &address->peer.hashPubKey, session));
+      disconnect_session (session);
+      session = NULL;
+    }
   }
 
   /* create new outbound session */
@@ -1141,7 +1154,7 @@ tcp_plugin_get_session (void *cls,
 #if DEBUG_TCP
     GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
                      "Failed to create connection to `%4s' at `%s'\n",
-                     GNUNET_i2s (&session->target), GNUNET_a2s (sb, sbs));
+                     GNUNET_i2s (&address->peer), GNUNET_a2s (sb, sbs));
 #endif
     return NULL;
   }
-- 
1.7.4

Activities

LRN

2012-02-29 14:24

reporter   ~0005541

Last edited: 2012-02-29 14:25

17:19:40-00000000000803043794 tcp-11956 DEBUG Received WELCOME message from `B2O8'
17:19:40-00000000000803043794 tcp-11956 DEBUG Creating new session for peer `B2O8'
17:19:40-00000000000803043794 tcp-11956 DEBUG Passing 16 bytes of type 375 from `B2O8' to transport service.
17:19:40-00000000000803043794 tcp-11956 DEBUG Transmitting message of type 61
17:19:40-00000000000803043794 tcp-11956 DEBUG Transmitting 68 bytes
17:19:40-00000000000803043795 tcp-11956 DEBUG Asked to transmit 16 bytes to `5SSL', added message to list.
17:19:40-00000000000803043796 tcp-11956 DEBUG Transmitting message of type 375
17:19:40-00000000000803043796 tcp-11956 DEBUG Transmitting 16 bytes
17:19:40-00000000000803043796 tcp-11956 DEBUG Asked to transmit 16 bytes to `B2O8', added message to list.
17:19:40-00000000000803043796 tcp-11956 DEBUG Transmitting message of type 376
17:19:40-00000000000803043796 tcp-11956 DEBUG Transmitting 16 bytes
17:19:40-00000000000803043841 tcp-11956 DEBUG Passing 4 bytes of type 377 from `B2O8' to transport service.
17:19:40-00000000000803043841 tcp-11956 DEBUG Passing 4 bytes of type 381 from `B2O8' to transport service.
17:19:40-00000000000803043841 tcp-11956 DEBUG Asked to transmit 4 bytes to `B2O8', added message to list.
17:19:40-00000000000803043841 tcp-11956 DEBUG Transmitting message of type 382
17:19:40-00000000000803043841 tcp-11956 DEBUG Transmitting 4 bytes
17:19:40-00000000000803043841 tcp-11956 DEBUG Passing 416 bytes of type 16 from `B2O8' to transport service.
17:19:40-00000000000803043841 transport-11956 DEBUG Adding `HELLO' without addresses for peer `B2O8'
17:19:40-00000000000803043842 tcp-11956 DEBUG Passing 82 bytes of type 372 from `B2O8' to transport service.
17:19:40-00000000000803043854 tcp-11956 DEBUG Asked to transmit 294 bytes to `B2O8', added message to list.
17:19:40-00000000000803043854 transport-11956 DEBUG Transmitted PONG to `B2O8' via reliable mechanism
17:19:40-00000000000803043854 tcp-11956 DEBUG Asked to transmit 4 bytes to `B2O8', added message to list.
17:19:40-00000000000803043854 tcp-11956 DEBUG Transmitting message of type 373
17:19:40-00000000000803043854 tcp-11956 DEBUG Transmitting 294 bytes
17:19:40-00000000000803043854 transport-11956 DEBUG Transmitting plain PING to `B2O8' 141.2.187.12:0
17:19:40-00000000000803043854 tcp-11956 DEBUG Trying to get session for `141.2.187.12:0' address length 6
17:19:40-00000000000803043854 tcp-11956 DEBUG Found valid IPv4 NAT address (creating session)!
17:19:40-00000000000803043854 tcp-11956 DEBUG Creating new session for peer `B2O8'
17:19:40-00000000000803043854 tcp-11956 DEBUG Created NAT WAIT connection to `B2O8' at `141.2.187.12'
17:19:40-00000000000803043854 transport-11956 ERROR Assertion failed at plugin_transport_tcp.c:904.


LRN

2012-02-29 15:42

reporter   ~0005545

0001-Try-to-not-to-create-dead-end-NAT-sessions.patch - a quick&dirty hack to cover this issue up.

LRN

2012-03-02 13:28

reporter   ~0005555

LRN: HELLO validator asks tcp for a session to that address, to transfer a PING message, tcp plugins creates a NAT WAIT sessions, with client == NULL (since it is not connected yet).
LRN: so, since i have nat client disabled, GNUNET_NAT_run_client() (which is what tcp plugin calls) returns without doing anything. And i get a session with client == NULL, and that's not going to change

Matthias Wachs

2012-03-02 15:05

reporter   ~0005556

wait for feedback

Matthias Wachs

2012-03-02 16:40

reporter   ~0005557

fixed in 20205

Issue History

Date Modified Username Field Change
2012-02-29 14:01 LRN New Issue
2012-02-29 14:01 LRN Status new => assigned
2012-02-29 14:01 LRN Assigned To => Matthias Wachs
2012-02-29 14:24 LRN Note Added: 0005541
2012-02-29 14:25 LRN Note Edited: 0005541
2012-02-29 15:42 LRN File Added: 0001-Try-to-not-to-create-dead-end-NAT-sessions.patch
2012-02-29 15:42 LRN Note Added: 0005545
2012-03-02 13:28 LRN Note Added: 0005555
2012-03-02 15:05 Matthias Wachs Note Added: 0005556
2012-03-02 15:05 Matthias Wachs Status assigned => feedback
2012-03-02 15:05 Matthias Wachs Resolution open => fixed
2012-03-02 16:40 Matthias Wachs Note Added: 0005557
2012-03-02 16:40 Matthias Wachs Status feedback => resolved
2012-03-02 20:35 Christian Grothoff Fixed in Version => 0.9.3
2012-03-02 20:35 Christian Grothoff Target Version => 0.9.3
2012-06-02 19:15 Christian Grothoff Status resolved => closed
2024-05-03 13:59 Christian Grothoff Category TCP transport => transport service