diff options
-rw-r--r-- | src/common/backtrace.c | 6 | ||||
-rw-r--r-- | src/or/connection_edge.c | 33 | ||||
-rw-r--r-- | src/or/or.h | 7 |
3 files changed, 40 insertions, 6 deletions
diff --git a/src/common/backtrace.c b/src/common/backtrace.c index 8d544ed704..bed0442471 100644 --- a/src/common/backtrace.c +++ b/src/common/backtrace.c @@ -96,7 +96,7 @@ log_backtrace(int severity, int domain, const char *msg) tor_mutex_acquire(&cb_buf_mutex); depth = backtrace(cb_buf, MAX_DEPTH); - symbols = backtrace_symbols(cb_buf, depth); + symbols = backtrace_symbols(cb_buf, (int)depth); tor_log(severity, domain, "%s. Stack trace:", msg); if (!symbols) { @@ -139,7 +139,7 @@ crash_handler(int sig, siginfo_t *si, void *ctx_) n_fds = tor_log_get_sigsafe_err_fds(&fds); for (i=0; i < n_fds; ++i) - backtrace_symbols_fd(cb_buf, depth, fds[i]); + backtrace_symbols_fd(cb_buf, (int)depth, fds[i]); abort(); } @@ -175,7 +175,7 @@ install_bt_handler(void) * reads won't be denied by the sandbox code */ char **symbols; size_t depth = backtrace(cb_buf, MAX_DEPTH); - symbols = backtrace_symbols(cb_buf, depth); + symbols = backtrace_symbols(cb_buf, (int) depth); if (symbols) free(symbols); } diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 30dcd13f4a..961e49abd9 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -765,6 +765,7 @@ connection_ap_rescan_and_attach_pending(void) continue; entry_conn = TO_ENTRY_CONN(conn); + tor_assert(entry_conn); if (! smartlist_contains(pending_entry_connections, entry_conn)) { log_warn(LD_BUG, "Found a connection %p that was supposed to be " "in pending_entry_connections, but wasn't. No worries; " @@ -779,6 +780,15 @@ connection_ap_rescan_and_attach_pending(void) connection_ap_attach_pending(1); } +#ifdef DEBUGGING_17659 +#define UNMARK() do { \ + entry_conn->marked_pending_circ_line = 0; \ + entry_conn->marked_pending_circ_file = 0; \ + } while (0) +#else +#define UNMARK() do { } while (0) +#endif + /** Tell any AP streams that are listed as waiting for a new circuit to try * again, either attaching to an available circ or launching a new one. * @@ -798,13 +808,16 @@ connection_ap_attach_pending(int retry) SMARTLIST_FOREACH_BEGIN(pending_entry_connections, entry_connection_t *, entry_conn) { connection_t *conn = ENTRY_TO_CONN(entry_conn); + tor_assert(conn && entry_conn); if (conn->marked_for_close) { + UNMARK(); SMARTLIST_DEL_CURRENT(pending_entry_connections, entry_conn); continue; } if (conn->magic != ENTRY_CONNECTION_MAGIC) { - log_warn(LD_BUG, "%p has impossible magic value %u", + log_warn(LD_BUG, "%p has impossible magic value %u.", entry_conn, (unsigned)conn->magic); + UNMARK(); SMARTLIST_DEL_CURRENT(pending_entry_connections, entry_conn); continue; } @@ -813,6 +826,7 @@ connection_ap_attach_pending(int retry) "is %s. Why is it on pending_entry_connections?", entry_conn, conn_state_to_string(conn->type, conn->state)); + UNMARK(); SMARTLIST_DEL_CURRENT(pending_entry_connections, entry_conn); continue; } @@ -826,6 +840,7 @@ connection_ap_attach_pending(int retry) if (conn->marked_for_close || conn->type != CONN_TYPE_AP || conn->state != AP_CONN_STATE_CIRCUIT_WAIT) { + UNMARK(); SMARTLIST_DEL_CURRENT(pending_entry_connections, entry_conn); continue; } @@ -860,12 +875,23 @@ connection_ap_mark_as_pending_circuit_(entry_connection_t *entry_conn, if (PREDICT_UNLIKELY(smartlist_contains(pending_entry_connections, entry_conn))) { log_warn(LD_BUG, "What?? pending_entry_connections already contains %p! " - "(called from %s:%d)", + "(Called from %s:%d.)", entry_conn, fname, lineno); - log_backtrace(LOG_WARN, LD_BUG, "To debug, this may help."); +#ifdef DEBUGGING_17659 + const char *f2 = entry_conn->marked_pending_circ_file; + log_warn(LD_BUG, "(Previously called from %s:%d.)\n", + f2 ? f2 : "<NULL>", + entry_conn->marked_pending_circ_line); +#endif + log_backtrace(LOG_WARN, LD_BUG, "To debug, this may help"); return; } +#ifdef DEBUGGING_17659 + entry_conn->marked_pending_circ_line = (uint16_t) lineno; + entry_conn->marked_pending_circ_file = fname; +#endif + untried_pending_connections = 1; smartlist_add(pending_entry_connections, entry_conn); } @@ -876,6 +902,7 @@ connection_ap_mark_as_non_pending_circuit(entry_connection_t *entry_conn) { if (PREDICT_UNLIKELY(NULL == pending_entry_connections)) return; + UNMARK(); smartlist_remove(pending_entry_connections, entry_conn); } diff --git a/src/or/or.h b/src/or/or.h index e92a4bba39..e621fe9708 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1646,6 +1646,13 @@ typedef struct entry_connection_t { * request that we're going to try to answer. */ struct evdns_server_request *dns_server_request; +#define DEBUGGING_17659 + +#ifdef DEBUGGING_17659 + uint16_t marked_pending_circ_line; + const char *marked_pending_circ_file; +#endif + #define NUM_CIRCUITS_LAUNCHED_THRESHOLD 10 /** Number of times we've launched a circuit to handle this stream. If * it gets too high, that could indicate an inconsistency between our |