[tor-commits] [tor/master] Check HT_REP_IS_BAD_() when giving a bug-7164 warning.

nickm at torproject.org nickm at torproject.org
Thu May 8 02:52:49 UTC 2014


commit a06044a485982bd91e380e71f3c5dc449782e75f
Author: Nick Mathewson <nickm at torproject.org>
Date:   Tue May 6 13:03:24 2014 -0400

    Check HT_REP_IS_BAD_() when giving a bug-7164 warning.
    
    This may let us know if we're hitting 7164 because of an
    hte_hash-corruption situation proposed by "cypherpunks" in bug
    11737.
---
 changes/bug11737_diagnostic |    5 +++++
 src/or/microdesc.c          |   18 ++++++++++++------
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/changes/bug11737_diagnostic b/changes/bug11737_diagnostic
new file mode 100644
index 0000000..62e7a4a
--- /dev/null
+++ b/changes/bug11737_diagnostic
@@ -0,0 +1,5 @@
+  o Minor features (diagnostic):
+    - When logging a warning because of bug #7164, additionally check the
+      hash table for consistency (as proposed on ticket #11737). This may
+      help diagnose bug #7164.
+
diff --git a/src/or/microdesc.c b/src/or/microdesc.c
index ec85de0..fdb549a 100644
--- a/src/or/microdesc.c
+++ b/src/or/microdesc.c
@@ -386,18 +386,21 @@ microdesc_cache_clean(microdesc_cache_t *cache, time_t cutoff, int force)
         smartlist_t *nodes = nodelist_find_nodes_with_microdesc(*mdp);
         const networkstatus_t *ns = networkstatus_get_latest_consensus();
         long networkstatus_age = -1;
+        const int ht_badness = HT_REP_IS_BAD_(microdesc_map, &cache->map);
         if (ns) {
           networkstatus_age = now - ns->valid_after;
         }
         log_warn(LD_BUG, "Microdescriptor seemed very old "
                  "(last listed %d hours ago vs %d hour cutoff), but is still "
                  "marked as being held by %d node(s). I found %d node(s) "
-                 "holding it. Current networkstatus is %ld hours old.",
+                 "holding it. Current networkstatus is %ld hours old. "
+                 "Hashtable badness is %d.",
                  (int)((now - (*mdp)->last_listed) / 3600),
                  (int)((now - cutoff) / 3600),
                  held_by_nodes,
                  smartlist_len(nodes),
-                 networkstatus_age / 3600);
+                 networkstatus_age / 3600,
+                 ht_badness);
 
         SMARTLIST_FOREACH_BEGIN(nodes, const node_t *, node) {
           const char *rs_match = "No RS";
@@ -664,8 +667,10 @@ microdesc_free_(microdesc_t *md, const char *fname, int lineno)
     tor_fragile_assert();
   }
   if (md->held_by_nodes) {
+    microdesc_cache_t *cache = get_microdesc_cache();
     int found=0;
     const smartlist_t *nodes = nodelist_get_list();
+    const int ht_badness = HT_REP_IS_BAD_(microdesc_map, &cache->map);
     SMARTLIST_FOREACH(nodes, node_t *, node, {
         if (node->md == md) {
           ++found;
@@ -674,12 +679,13 @@ microdesc_free_(microdesc_t *md, const char *fname, int lineno)
       });
     if (found) {
       log_warn(LD_BUG, "microdesc_free() called from %s:%d, but md was still "
-               "referenced %d node(s); held_by_nodes == %u",
-               fname, lineno, found, md->held_by_nodes);
+               "referenced %d node(s); held_by_nodes == %u, ht_badness == %d",
+               fname, lineno, found, md->held_by_nodes, ht_badness);
     } else {
       log_warn(LD_BUG, "microdesc_free() called from %s:%d with held_by_nodes "
-               "set to %u, but md was not referenced by any nodes",
-               fname, lineno, md->held_by_nodes);
+               "set to %u, but md was not referenced by any nodes. "
+               "ht_badness == %d",
+               fname, lineno, md->held_by_nodes, ht_badness);
     }
     tor_fragile_assert();
   }





More information about the tor-commits mailing list