]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Avoid attempts to double-remove edge connections from the DNS resolver.
authorNick Mathewson <nickm@torproject.org>
Thu, 8 Jan 2015 16:00:21 +0000 (11:00 -0500)
committerNick Mathewson <nickm@torproject.org>
Thu, 8 Jan 2015 16:00:21 +0000 (11:00 -0500)
Also, avoid crashing when we attempt to double-remove an edge
connection from the DNS resolver: just log a bug warning instead.

Fixes bug 14129.  Bugfix on 0d20fee2fbd48978, which was in 0.0.7rc1.

jowr found the bug.  cypherpunks wrote the fix.  I added the log
message and removed the assert.

changes/bug14129 [new file with mode: 0644]
src/or/dns.c

diff --git a/changes/bug14129 b/changes/bug14129
new file mode 100644 (file)
index 0000000..6153cd8
--- /dev/null
@@ -0,0 +1,7 @@
+  o Major bugfixes (exit node stability):
+
+    - Fix an assertion failure that could occur under high DNS load.  Fixes
+      bug 14129; bugfix on Tor 0.0.7rc1. Found by "jowr"; diagnosed and fixed
+      by "cypherpunks".
+
+
index fb1b10d82c8e74e7281dd1063f7c2e73dfa4ab7b..8b6e3b0543ff8d20b73b89ce070acb03fc0885cb 100644 (file)
@@ -557,6 +557,8 @@ purge_expired_resolves(time_t now)
         /* Connections should only be pending if they have no socket. */
         tor_assert(!SOCKET_OK(pend->conn->base_.s));
         pendconn = pend->conn;
+        /* Prevent double-remove */
+        pendconn->base_.state = EXIT_CONN_STATE_RESOLVEFAILED;
         if (!pendconn->base_.marked_for_close) {
           connection_edge_end(pendconn, END_STREAM_REASON_TIMEOUT);
           circuit_detach_stream(circuit_get_by_edge_conn(pendconn), pendconn);
@@ -1132,7 +1134,9 @@ connection_dns_remove(edge_connection_t *conn)
         return; /* more are pending */
       }
     }
-    tor_assert(0); /* not reachable unless onlyconn not in pending list */
+    log_warn(LD_BUG, "Connection (fd "TOR_SOCKET_T_FORMAT") was not waiting "
+             "for a resolve of %s, but we tried to remove it.",
+             conn->base_.s, escaped_safe_str(conn->base_.address));
   }
 }