View Issue Details

IDProjectCategoryView StatusLast Update
0008807GNUnetpeerstorepublic2024-06-08 12:03
Reporterulfvonbelow Assigned Toschanzen  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformx86-64OSGuix SystemOS Versiona1d711c92e
Product VersionGit master 
Fixed in Version0.21.2 
Summary0008807: memory leak when freeing struct Iteration in gnunet-service-peerstore
Descriptionthe sub_system and key fields are only freed in iteration_done_client_continue, not in handle_iterate_stop or client_disconnect_cb.
Steps To ReproduceNot sure, the tests didn't catch this, it just showed up in my logs, most likely when I stopped all the services with "gnunet-arm -e".
Additional InformationPatch attached.
TagsNo tags attached.
Attached Files
0001-peerstore-fix-Iteration-memory-leak-in-gnunet-servic.patch (1,842 bytes)   
From 4109ffd018ee26e6b70b9de2a8f501b7e32696ee Mon Sep 17 00:00:00 2001
From: ulfvonbelow <striness@tilde.club>
Date: Sat, 4 May 2024 18:09:51 -0500
Subject: [PATCH] peerstore: fix Iteration memory leak in
 gnunet-service-peerstore.

---
 .../peerstore/gnunet-service-peerstore.c        | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/service/peerstore/gnunet-service-peerstore.c b/src/service/peerstore/gnunet-service-peerstore.c
index 5d0f037a1..3eb224ae8 100644
--- a/src/service/peerstore/gnunet-service-peerstore.c
+++ b/src/service/peerstore/gnunet-service-peerstore.c
@@ -491,6 +491,15 @@ iterate_proc (void *cls,
   proc->limit--;
 }
 
+
+static void destroy_iteration(struct Iteration *ic)
+{
+  GNUNET_free (ic->key);
+  GNUNET_free (ic->sub_system);
+  GNUNET_free (ic);
+}
+
+
 /**
  * Function called once we are done with the iteration and
  * allow the zone iteration client to send us more messages.
@@ -512,10 +521,8 @@ iteration_done_client_continue (struct Iteration *ic)
   endmsg->rid = htons (ic->request_id);
   endmsg->result = htonl (GNUNET_OK);
   GNUNET_MQ_send (ic->pc->mq, env);
-  GNUNET_free (ic->key);
-  GNUNET_free (ic->sub_system);
   GNUNET_CONTAINER_DLL_remove (ic->pc->op_head, ic->pc->op_tail, ic);
-  GNUNET_free (ic);
+  destroy_iteration (ic);
   return;
 }
 
@@ -657,7 +664,7 @@ handle_iterate_stop (void *cls,
     return;
   }
   GNUNET_CONTAINER_DLL_remove (pc->op_head, pc->op_tail, ic);
-  GNUNET_free (ic);
+  destroy_iteration (ic);
   GNUNET_SERVICE_client_continue (pc->client);
 }
 
@@ -1098,7 +1105,7 @@ client_disconnect_cb (void *cls,
   while (NULL != (iter = pc->op_head))
   {
     GNUNET_CONTAINER_DLL_remove (pc->op_head, pc->op_tail, iter);
-    GNUNET_free (iter);
+    destroy_iteration (iter);
   }
   GNUNET_free (pc);
 }
-- 
2.41.0

Activities

schanzen

2024-05-13 10:44

administrator   ~0022390

Applied

schanzen

2024-06-08 12:03

administrator   ~0022538

0.21.2 released

Issue History

Date Modified Username Field Change
2024-05-07 04:53 ulfvonbelow New Issue
2024-05-07 04:53 ulfvonbelow File Added: 0001-peerstore-fix-Iteration-memory-leak-in-gnunet-servic.patch
2024-05-13 10:44 schanzen Assigned To => schanzen
2024-05-13 10:44 schanzen Status new => resolved
2024-05-13 10:44 schanzen Resolution open => fixed
2024-05-13 10:44 schanzen Fixed in Version => 0.21.2
2024-05-13 10:44 schanzen Note Added: 0022390
2024-06-08 12:03 schanzen Note Added: 0022538
2024-06-08 12:03 schanzen Status resolved => closed