From 66c81802076811cf2e329525a0fc9cb38a1e3608 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 12 Mar 2015 11:13:57 -0400 Subject: [PATCH 1/3] 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 0000000000..520a370eeb --- /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 09ffdb81d1..588eae9fc8 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 2/3] 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 588eae9fc8..e3781ada1c 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 3/3] 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 e3781ada1c..d511ecf84c 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,