Merge remote-tracking branch 'mikeperry/bug25733_029' into maint-0.3.3

This commit is contained in:
Nick Mathewson 2018-05-07 13:33:12 -04:00
commit 46002aa691
2 changed files with 22 additions and 2 deletions

4
changes/bug25733 Normal file
View File

@ -0,0 +1,4 @@
o Minor bugfixes (Assert crash):
- Avoid an assert in the circuit build timeout code if we fail to
allow any circuits to actually complete. Fixes bug 25733;
bugfix on 0.2.2.2-alpha.

View File

@ -892,11 +892,23 @@ circuit_build_times_get_xm(circuit_build_times_t *cbt)
histogram[nth_max_bin[n]]); histogram[nth_max_bin[n]]);
} }
/* The following assert is safe, because we don't get called when we /* bin_counts can become zero if all of our last CBT_NCIRCUITS_TO_OBSERVE
* haven't observed at least CBT_MIN_MIN_CIRCUITS_TO_OBSERVE circuits. */ * circuits were abandoned before they completed. This shouldn't happen,
* though. We should have reset/re-learned a lower timeout first. */
if (bin_counts == 0) {
ret = 0;
log_warn(LD_CIRC,
"No valid circuit build time data out of %d times, %u modes, "
"have_timeout=%d, %lfms", cbt->total_build_times, num_modes,
cbt->have_computed_timeout, cbt->timeout_ms);
goto done;
}
tor_assert(bin_counts > 0); tor_assert(bin_counts > 0);
ret /= bin_counts; ret /= bin_counts;
done:
tor_free(histogram); tor_free(histogram);
tor_free(nth_max_bin); tor_free(nth_max_bin);
@ -1182,6 +1194,10 @@ circuit_build_times_update_alpha(circuit_build_times_t *cbt)
* and less frechet-like. */ * and less frechet-like. */
cbt->Xm = circuit_build_times_get_xm(cbt); cbt->Xm = circuit_build_times_get_xm(cbt);
/* If Xm came back 0, then too many circuits were abandoned. */
if (cbt->Xm == 0)
return 0;
tor_assert(cbt->Xm > 0); tor_assert(cbt->Xm > 0);
for (i=0; i< CBT_NCIRCUITS_TO_OBSERVE; i++) { for (i=0; i< CBT_NCIRCUITS_TO_OBSERVE; i++) {