Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D5115200BCF for ; Mon, 5 Dec 2016 08:26:25 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id D3C75160B21; Mon, 5 Dec 2016 07:26:25 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 32F85160AF9 for ; Mon, 5 Dec 2016 08:26:25 +0100 (CET) Received: (qmail 96748 invoked by uid 500); 5 Dec 2016 07:26:24 -0000 Mailing-List: contact commits-help@kudu.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@kudu.apache.org Delivered-To: mailing list commits@kudu.apache.org Received: (qmail 96735 invoked by uid 99); 5 Dec 2016 07:26:24 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Dec 2016 07:26:24 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 36F77E962C; Mon, 5 Dec 2016 07:26:24 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: todd@apache.org To: commits@kudu.apache.org Date: Mon, 05 Dec 2016 07:26:24 -0000 Message-Id: <93a85c7b039842698b5f23edaa9dc94f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] kudu git commit: ssl_factory: avoid a non-POD (vector<>) in static storage archived-at: Mon, 05 Dec 2016 07:26:26 -0000 Repository: kudu Updated Branches: refs/heads/master 47c25ceae -> 0ac14a564 ssl_factory: avoid a non-POD (vector<>) in static storage The global vector in static storage was causing ASAN test failures when I looped rpc-test's keepalive test with SSL enabled[1]. The issue is that the static storage destructor could run concurrently with other threads still trying to access the SSL mutexes. Since this mutex list is purposefully leaked anyway, it's better to just use a C-style array. [1] http://dist-test.cloudera.org/job?job_id=todd.1480910327.10622 Change-Id: I859aefd932d62fa8619650fcc795d3676187ceb4 Reviewed-on: http://gerrit.cloudera.org:8080/5354 Reviewed-by: Adar Dembo Tested-by: Kudu Jenkins Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/a6cf13f4 Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/a6cf13f4 Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/a6cf13f4 Branch: refs/heads/master Commit: a6cf13f4a3d448fff0cd049cf18196c20696d940 Parents: 47c25ce Author: Todd Lipcon Authored: Mon Dec 5 12:11:24 2016 +0800 Committer: Todd Lipcon Committed: Mon Dec 5 07:04:28 2016 +0000 ---------------------------------------------------------------------- src/kudu/util/net/ssl_factory.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/a6cf13f4/src/kudu/util/net/ssl_factory.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/net/ssl_factory.cc b/src/kudu/util/net/ssl_factory.cc index 4fefb45..b8016a4 100644 --- a/src/kudu/util/net/ssl_factory.cc +++ b/src/kudu/util/net/ssl_factory.cc @@ -33,14 +33,14 @@ namespace kudu { // These non-POD elements will be alive for the lifetime of the process, so don't allocate in // static storage. -static std::vector ssl_mutexes; +static Mutex* g_ssl_mutexes; // Lock/Unlock the nth lock. Only to be used by OpenSSL. static void CryptoLockingCallback(int mode, int n, const char* /*unused*/, int /*unused*/) { if (mode & CRYPTO_LOCK) { - ssl_mutexes[n]->Acquire(); + g_ssl_mutexes[n].Acquire(); } else { - ssl_mutexes[n]->Release(); + g_ssl_mutexes[n].Release(); } } @@ -55,10 +55,8 @@ void DoSSLInit() { OpenSSL_add_all_algorithms(); RAND_poll(); - for (int i = 0; i < CRYPTO_num_locks(); ++i) { - debug::ScopedLeakCheckDisabler d; - ssl_mutexes.push_back(new Mutex()); - } + debug::ScopedLeakCheckDisabler d; + g_ssl_mutexes = new Mutex[CRYPTO_num_locks()]; // Callbacks used by OpenSSL required in a multi-threaded setting. CRYPTO_set_locking_callback(CryptoLockingCallback);