From 985687bc4f99b90ed88ccdbefc820260c299ff23 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 10 Mar 2015 10:10:35 -0400 Subject: [PATCH 1/7] Fix check-spaces --- src/common/container.h | 1 - src/test/test_status.c | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/common/container.h b/src/common/container.h index d07697f01..457b5e4ea 100644 --- a/src/common/container.h +++ b/src/common/container.h @@ -256,7 +256,6 @@ char *smartlist_join_strings2(smartlist_t *sl, const char *join, --var ## _sl_len; \ STMT_END - /** Helper: While in a SMARTLIST_FOREACH loop over the list sl indexed * with the variable var, replace the current element with val. * Does not deallocate the current value of var. diff --git a/src/test/test_status.c b/src/test/test_status.c index 0aa82ca08..cb3b4f64c 100644 --- a/src/test/test_status.c +++ b/src/test/test_status.c @@ -878,7 +878,8 @@ NS(logv)(int severity, log_domain_mask_t domain, const char *funcname, tt_ptr_op(strstr(funcname, "log_heartbeat"), OP_NE, NULL); tt_ptr_op(suffix, OP_EQ, NULL); tt_str_op(format, OP_EQ, - "Average packaged cell fullness: %2.3f%%. TLS write overhead: %.f%%"); + "Average packaged cell fullness: %2.3f%%. " + "TLS write overhead: %.f%%"); tt_double_op(fabs(va_arg(ap, double) - 50.0), <=, DBL_EPSILON); tt_double_op(fabs(va_arg(ap, double) - 0.0), <=, DBL_EPSILON); break; @@ -1026,7 +1027,8 @@ NS(logv)(int severity, log_domain_mask_t domain, tt_ptr_op(strstr(funcname, "log_heartbeat"), OP_NE, NULL); tt_ptr_op(suffix, OP_EQ, NULL); tt_str_op(format, OP_EQ, - "Average packaged cell fullness: %2.3f%%. TLS write overhead: %.f%%"); + "Average packaged cell fullness: %2.3f%%. " + "TLS write overhead: %.f%%"); tt_int_op(fabs(va_arg(ap, double) - 100.0) <= DBL_EPSILON, OP_EQ, 1); tt_double_op(fabs(va_arg(ap, double) - 100.0), <=, DBL_EPSILON); break; From 192ed944101174d775d27ac54002ee9bc2708080 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 12 Mar 2015 09:49:45 -0400 Subject: [PATCH 2/7] Use PTHREAD_CREATE_DETACHED macro instead of 1: fix Solaris crash When calling pthread_attr_setdetachstate, we were using 1 as the argument. But the pthreads documentation says that you have to say PTHREAD_CREATE_DETACH, which on Solaris is apparently 0x40. Calling pthread_attr_setdetachstate with 1 crashes on Solaris with FLTBOUNDS. (Because we're so late in the release cycle, I made the code define PTHREAD_CREATE_DETACHED if it doesn't exist, so we aren't likely to break any other platforms.) This bug was introduced when we made threading mandatory in 0.2.6.1-alpha; previously, we had force-disabled threading on Solaris. See #9495 discussion. --- changes/bug9495_redux | 4 ++++ src/common/compat_pthreads.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 changes/bug9495_redux diff --git a/changes/bug9495_redux b/changes/bug9495_redux new file mode 100644 index 000000000..74b0cdf2a --- /dev/null +++ b/changes/bug9495_redux @@ -0,0 +1,4 @@ + o Major bugfixes (portability): + - Do not crash on startup when running on Solaris. Fixes a bug + related to our fix for 9495; bugfix on 0.2.6.1-alpha. Reported + by "ruebezahl". diff --git a/src/common/compat_pthreads.c b/src/common/compat_pthreads.c index f4a6cad15..246076b27 100644 --- a/src/common/compat_pthreads.c +++ b/src/common/compat_pthreads.c @@ -279,7 +279,11 @@ tor_threads_init(void) pthread_mutexattr_init(&attr_recursive); pthread_mutexattr_settype(&attr_recursive, PTHREAD_MUTEX_RECURSIVE); tor_assert(0==pthread_attr_init(&attr_detached)); - tor_assert(0==pthread_attr_setdetachstate(&attr_detached, 1)); +#ifndef PTHREAD_CREATE_DETACHED +#define PTHREAD_CREATE_DETACHED 1 +#endif + tor_assert(0==pthread_attr_setdetachstate(&attr_detached, + PTHREAD_CREATE_DETACHED)); threads_initialized = 1; set_main_thread(); } From 5f46a59ba394a1b45ecc1ee52514998e774d3dca Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 12 Mar 2015 10:50:15 -0400 Subject: [PATCH 3/7] Bump 0.2.4 version. --- configure.ac | 2 +- contrib/tor-mingw.nsi.in | 2 +- src/win32/orconfig.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 9cf172af4..5cc9ab881 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ dnl Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson dnl Copyright (c) 2007-2013, The Tor Project, Inc. dnl See LICENSE for licensing information -AC_INIT([tor],[0.2.4.25-dev]) +AC_INIT([tor],[0.2.4.26]) AC_CONFIG_SRCDIR([src/or/main.c]) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE diff --git a/contrib/tor-mingw.nsi.in b/contrib/tor-mingw.nsi.in index 1e578cd4a..f16e637de 100644 --- a/contrib/tor-mingw.nsi.in +++ b/contrib/tor-mingw.nsi.in @@ -8,7 +8,7 @@ !include "LogicLib.nsh" !include "FileFunc.nsh" !insertmacro GetParameters -!define VERSION "0.2.4.25-dev" +!define VERSION "0.2.4.26" !define INSTALLER "tor-${VERSION}-win32.exe" !define WEBSITE "https://www.torproject.org/" !define LICENSE "LICENSE" diff --git a/src/win32/orconfig.h b/src/win32/orconfig.h index d3f3eb19a..a028e9ec4 100644 --- a/src/win32/orconfig.h +++ b/src/win32/orconfig.h @@ -241,7 +241,7 @@ #define USING_TWOS_COMPLEMENT /* Version number of package */ -#define VERSION "0.2.4.25-dev" +#define VERSION "0.2.4.26" From a00d07ac1bddd84dd6109cae7afda970d5722d24 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 12 Mar 2015 10:52:09 -0400 Subject: [PATCH 4/7] Bump 025 version to 0.2.5.11 --- configure.ac | 2 +- contrib/win32build/tor-mingw.nsi.in | 2 +- src/win32/orconfig.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 8fab9758b..5372943c7 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ dnl Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson dnl Copyright (c) 2007-2013, The Tor Project, Inc. dnl See LICENSE for licensing information -AC_INIT([tor],[0.2.5.10-dev]) +AC_INIT([tor],[0.2.5.11]) AC_CONFIG_SRCDIR([src/or/main.c]) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE diff --git a/contrib/win32build/tor-mingw.nsi.in b/contrib/win32build/tor-mingw.nsi.in index fc4b81b11..a5b755734 100644 --- a/contrib/win32build/tor-mingw.nsi.in +++ b/contrib/win32build/tor-mingw.nsi.in @@ -8,7 +8,7 @@ !include "LogicLib.nsh" !include "FileFunc.nsh" !insertmacro GetParameters -!define VERSION "0.2.5.10-dev" +!define VERSION "0.2.5.11" !define INSTALLER "tor-${VERSION}-win32.exe" !define WEBSITE "https://www.torproject.org/" !define LICENSE "LICENSE" diff --git a/src/win32/orconfig.h b/src/win32/orconfig.h index b2490c33a..34e147157 100644 --- a/src/win32/orconfig.h +++ b/src/win32/orconfig.h @@ -241,7 +241,7 @@ #define USING_TWOS_COMPLEMENT /* Version number of package */ -#define VERSION "0.2.5.10-dev" +#define VERSION "0.2.5.11" From 66c81802076811cf2e329525a0fc9cb38a1e3608 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 12 Mar 2015 11:13:57 -0400 Subject: [PATCH 5/7] Fix crash bug when calling cpuworkers_rotate_keyinfo on a client. Fixes bug 15245; bugfix on 0.2.6.3-alpha. Thanks to anonym for reporting! --- changes/bug15245 | 5 +++++ src/or/cpuworker.c | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 changes/bug15245 diff --git a/changes/bug15245 b/changes/bug15245 new file mode 100644 index 000000000..520a370ee --- /dev/null +++ b/changes/bug15245 @@ -0,0 +1,5 @@ + o Major bugfixes: + - Avoid crashing when making certain configuration option changes + on clients. Fixes bug 15245; bugfix on 0.2.6.3-alpha. Reported + by "anonym". + diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index 09ffdb81d..588eae9fc 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -178,6 +178,8 @@ update_state_threadfn(void *state_, void *work_) void cpuworkers_rotate_keyinfo(void) { + if (!threadpool) + return; if (threadpool_queue_update(threadpool, worker_state_new, update_state_threadfn, From 648af0438d4a293f12b649afc47dd947a7666a05 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 12 Mar 2015 11:15:50 -0400 Subject: [PATCH 6/7] Also, add an assertion to assign_onionskin_to_cpuworker --- src/or/cpuworker.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index 588eae9fc..e3781ada1 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -488,6 +488,8 @@ assign_onionskin_to_cpuworker(or_circuit_t *circ, cpuworker_request_t req; int should_time; + tor_assert(threadpool); + if (!circ->p_chan) { log_info(LD_OR,"circ->p_chan gone. Failing circ."); tor_free(onionskin); From d4c17162632b662c333fb09b930838c3884a6fc7 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 12 Mar 2015 11:28:18 -0400 Subject: [PATCH 7/7] add an explanatory comment --- src/or/cpuworker.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index e3781ada1..d511ecf84 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -178,8 +178,12 @@ update_state_threadfn(void *state_, void *work_) void cpuworkers_rotate_keyinfo(void) { - if (!threadpool) + if (!threadpool) { + /* If we're a client, then we won't have cpuworkers, and we won't need + * to tell them to rotate their state. + */ return; + } if (threadpool_queue_update(threadpool, worker_state_new, update_state_threadfn,