From 4bfed4378d3b101757e50b058e3d462fa88ecfd3 Mon Sep 17 00:00:00 2001 From: Mike Perry Date: Mon, 17 Sep 2012 18:25:28 -0700 Subject: [PATCH 1/2] Bug 6866: Convert pathbias asserts into log messages. Asserts were hit by Tor2Web mode. --- changes/bug6866 | 4 ++++ src/or/circuitbuild.c | 40 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 changes/bug6866 diff --git a/changes/bug6866 b/changes/bug6866 new file mode 100644 index 0000000000..561676b765 --- /dev/null +++ b/changes/bug6866 @@ -0,0 +1,4 @@ + o Minor bugfixes: + - Convert an assert in the pathbias code to a log message. Assert + appears to only be triggerable by Tor2Web mode. Fixes bug 6866; + bugfix on 0.2.3.17-beta. diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 9d52b5e021..6bd1eb32e7 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -2646,8 +2646,24 @@ pathbias_count_first_hop(origin_circuit_t *circ) char *rate_msg = NULL; /* Completely ignore one hop circuits */ - if (circ->build_state->onehop_tunnel) { - tor_assert(circ->build_state->desired_path_len == 1); + if (circ->build_state->onehop_tunnel || + circ->build_state->desired_path_len == 1) { + /* Check for inconsistency */ + if (circ->build_state->desired_path_len != 1 || + !circ->build_state->onehop_tunnel) { + if ((rate_msg = rate_limit_log(&first_hop_notice_limit, + approx_time()))) { + log_info(LD_BUG, + "One-hop circuit has length %d. Path state is %s. " + "Circuit is a %s currently %s. %s", + circ->build_state->desired_path_len, + pathbias_state_to_string(circ->path_state), + circuit_purpose_to_string(circ->_base.purpose), + circuit_state_to_string(circ->_base.state), + rate_msg); + } + tor_fragile_assert(); + } return 0; } @@ -2740,8 +2756,24 @@ pathbias_count_success(origin_circuit_t *circ) char *rate_msg = NULL; /* Ignore one hop circuits */ - if (circ->build_state->onehop_tunnel) { - tor_assert(circ->build_state->desired_path_len == 1); + if (circ->build_state->onehop_tunnel || + circ->build_state->desired_path_len == 1) { + /* Check for consistency */ + if (circ->build_state->desired_path_len != 1 || + !circ->build_state->onehop_tunnel) { + if ((rate_msg = rate_limit_log(&success_notice_limit, + approx_time()))) { + log_info(LD_BUG, + "One-hop circuit has length %d. Path state is %s. " + "Circuit is a %s currently %s. %s", + circ->build_state->desired_path_len, + pathbias_state_to_string(circ->path_state), + circuit_purpose_to_string(circ->_base.purpose), + circuit_state_to_string(circ->_base.state), + rate_msg); + } + tor_fragile_assert(); + } return; } From aca325eb0c6b34ba0e1ef8df16c1cf44a98f9b6f Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 18 Sep 2012 16:16:17 -0400 Subject: [PATCH 2/2] Whitespace fixes --- src/or/circuitbuild.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 6bd1eb32e7..ffc7b5eaf8 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -2646,11 +2646,11 @@ pathbias_count_first_hop(origin_circuit_t *circ) char *rate_msg = NULL; /* Completely ignore one hop circuits */ - if (circ->build_state->onehop_tunnel || - circ->build_state->desired_path_len == 1) { + if (circ->build_state->onehop_tunnel || + circ->build_state->desired_path_len == 1) { /* Check for inconsistency */ - if (circ->build_state->desired_path_len != 1 || - !circ->build_state->onehop_tunnel) { + if (circ->build_state->desired_path_len != 1 || + !circ->build_state->onehop_tunnel) { if ((rate_msg = rate_limit_log(&first_hop_notice_limit, approx_time()))) { log_info(LD_BUG, @@ -2756,11 +2756,11 @@ pathbias_count_success(origin_circuit_t *circ) char *rate_msg = NULL; /* Ignore one hop circuits */ - if (circ->build_state->onehop_tunnel || - circ->build_state->desired_path_len == 1) { + if (circ->build_state->onehop_tunnel || + circ->build_state->desired_path_len == 1) { /* Check for consistency */ - if (circ->build_state->desired_path_len != 1 || - !circ->build_state->onehop_tunnel) { + if (circ->build_state->desired_path_len != 1 || + !circ->build_state->onehop_tunnel) { if ((rate_msg = rate_limit_log(&success_notice_limit, approx_time()))) { log_info(LD_BUG,