[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] test: Increment rend cache allocation before freeing



commit 47f1d19f8e6e1795ad7a73cb96bf44f355442e85
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date:   Thu Sep 17 12:55:40 2020 -0400

    test: Increment rend cache allocation before freeing
    
    The rend_cache/entry_free was missing the rend cache allocation increment
    before freeing the object.
    
    Without it, it had an underflow bug:
    
      Sep 17 08:40:13.845 [warn] rend_cache_decrement_allocation(): Bug: Underflow
      in rend_cache_decrement_allocation (on Tor 0.4.5.0-alpha-dev
      7eef9ced61e72b1d)
    
    Fixes #40125
    
    Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
 changes/ticket40125       | 4 ++++
 src/test/test_rendcache.c | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/changes/ticket40125 b/changes/ticket40125
new file mode 100644
index 0000000000..c68e3ce7b3
--- /dev/null
+++ b/changes/ticket40125
@@ -0,0 +1,4 @@
+  o Testing (onion service v2):
+    - Fix a rendezvous cache unit test that was triggering an underflow on the
+      global rend cache allocation. Fixes bug 40125; bugfix on
+      0.2.8.1-alpha.
diff --git a/src/test/test_rendcache.c b/src/test/test_rendcache.c
index 93f9f82953..92e135f3b1 100644
--- a/src/test/test_rendcache.c
+++ b/src/test/test_rendcache.c
@@ -978,11 +978,13 @@ test_rend_cache_entry_free(void *data)
 
   // Handles NULL descriptor correctly
   e = tor_malloc_zero(sizeof(rend_cache_entry_t));
+  rend_cache_increment_allocation(rend_cache_entry_allocation(e));
   rend_cache_entry_free(e);
 
   // Handles non-NULL descriptor correctly
   e = tor_malloc_zero(sizeof(rend_cache_entry_t));
   e->desc = tor_malloc(10);
+  rend_cache_increment_allocation(rend_cache_entry_allocation(e));
   rend_cache_entry_free(e);
 
  /* done: */



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits