View Issue Details

IDProjectCategoryView StatusLast Update
0008816GNUnettransport servicepublic2024-06-08 12:03
Reporterulfvonbelow Assigned Toschanzen  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformx86-64OSGuix SystemOS Versiona1d711c92e
Product VersionGit master 
Fixed in Version0.21.2 
Summary0008816: tcp communicator creates multiple statistics handles
Descriptioninit_socket can be called multiple times, and each time it unconditionally calls GNUNET_STATISTICS_create, even if stats is already set. All handles except the most recent will be leaked.
Steps To Reproduce1. Build gnunet with --enable-sanitizer
2. Start the node with gnunet-arm -s
3. Stop the node after a bit with gnunet-arm -e
4. Observe reported memory leak wherever you've configured communicator-tcp to log to, provided that you have more than one address to bind to
Additional InformationIt's not clear to me why the statistics connection is being made in this particular place, but it's a pretty easy fix regardless. Patch attached.
TagsNo tags attached.
Attached Files
0001-transport-only-create-one-statistics-handle-in-tcp-c.patch (1,021 bytes)   
From 7ebb7fb93f674459bed6f1c299b67aba2b3447f8 Mon Sep 17 00:00:00 2001
From: ulfvonbelow <striness@tilde.club>
Date: Sun, 5 May 2024 12:28:45 -0500
Subject: [PATCH] transport: only create one statistics handle in tcp
 communicator.

---
 src/service/transport/gnunet-communicator-tcp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/service/transport/gnunet-communicator-tcp.c b/src/service/transport/gnunet-communicator-tcp.c
index 1e0d47776..02f5fc9f9 100644
--- a/src/service/transport/gnunet-communicator-tcp.c
+++ b/src/service/transport/gnunet-communicator-tcp.c
@@ -3798,7 +3798,8 @@ init_socket (struct sockaddr *addr,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Bound to `%s'\n",
               GNUNET_a2s ((const struct sockaddr *) &in_sto, sto_len));
-  stats = GNUNET_STATISTICS_create ("communicator-tcp", cfg);
+  if (NULL == stats)
+    stats = GNUNET_STATISTICS_create ("communicator-tcp", cfg);
 
   if (NULL == is)
     is = GNUNET_NT_scanner_init ();
-- 
2.41.0

Activities

schanzen

2024-05-13 10:39

administrator   ~0022385

Applied

schanzen

2024-06-08 12:03

administrator   ~0022542

0.21.2 released

Issue History

Date Modified Username Field Change
2024-05-07 06:06 ulfvonbelow New Issue
2024-05-07 06:06 ulfvonbelow File Added: 0001-transport-only-create-one-statistics-handle-in-tcp-c.patch
2024-05-13 10:39 schanzen Assigned To => schanzen
2024-05-13 10:39 schanzen Status new => resolved
2024-05-13 10:39 schanzen Resolution open => fixed
2024-05-13 10:39 schanzen Fixed in Version => 0.21.2
2024-05-13 10:39 schanzen Note Added: 0022385
2024-06-08 12:03 schanzen Note Added: 0022542
2024-06-08 12:03 schanzen Status resolved => closed