From f8816f6e2aecc1168316f7efcb2f13c4c05f8ca6 Mon Sep 17 00:00:00 2001 From: Robert Nishihara Date: Thu, 31 May 2018 16:23:01 -0700 Subject: [PATCH 01/12] Undo export pthread_once related symbols. --- cpp/src/arrow/symbols.map | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/cpp/src/arrow/symbols.map b/cpp/src/arrow/symbols.map index 10f6d7c3431..9faf38c9091 100644 --- a/cpp/src/arrow/symbols.map +++ b/cpp/src/arrow/symbols.map @@ -16,21 +16,11 @@ # under the License. { - global: - extern "C++" { - # Export pthread_once-related symbols so that two SO files - # (e.g. libarrow.so and libplasma.so) don't use separate copies of - # those symbols. - # See https://github.com/apache/arrow/pull/1953#issuecomment-386057063 - std::__once*; - }; - # Symbols marked as 'local' are not exported by the DSO and thus may not # be used by client applications. local: # devtoolset / static-libstdc++ symbols __cxa_*; - __once_proxy; # Static libraries that are linked in e.g. the manylinux1 build # Brotli compression library From 8179d0d5b9587de91ae13c045f9e82a76db5e591 Mon Sep 17 00:00:00 2001 From: Robert Nishihara Date: Sat, 2 Jun 2018 16:20:34 -0700 Subject: [PATCH 02/12] Add exceptions to visibility check. --- python/manylinux1/Dockerfile-x86_64 | 4 +-- ...isibility.sh => check_arrow_visibility.py} | 26 ++++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) rename python/manylinux1/scripts/{check_arrow_visibility.sh => check_arrow_visibility.py} (59%) mode change 100755 => 100644 diff --git a/python/manylinux1/Dockerfile-x86_64 b/python/manylinux1/Dockerfile-x86_64 index 5bd64d1d968..82418e0119e 100644 --- a/python/manylinux1/Dockerfile-x86_64 +++ b/python/manylinux1/Dockerfile-x86_64 @@ -23,8 +23,8 @@ WORKDIR /arrow/cpp/build-plain RUN cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/arrow-dist -DARROW_BUILD_TESTS=OFF -DARROW_BUILD_SHARED=ON -DARROW_BOOST_USE_SHARED=ON -DARROW_JEMALLOC=ON -DARROW_RPATH_ORIGIN=ON -DARROW_JEMALLOC_USE_SHARED=OFF -DBoost_NAMESPACE=arrow_boost -DBOOST_ROOT=/arrow_boost_dist .. RUN ninja install -ADD scripts/check_arrow_visibility.sh / -RUN /check_arrow_visibility.sh +ADD scripts/check_arrow_visibility.py / +RUN /check_arrow_visibility.py WORKDIR / RUN git clone https://github.com/apache/parquet-cpp.git diff --git a/python/manylinux1/scripts/check_arrow_visibility.sh b/python/manylinux1/scripts/check_arrow_visibility.py old mode 100755 new mode 100644 similarity index 59% rename from python/manylinux1/scripts/check_arrow_visibility.sh rename to python/manylinux1/scripts/check_arrow_visibility.py index bed357edf66..f34140e0b56 --- a/python/manylinux1/scripts/check_arrow_visibility.sh +++ b/python/manylinux1/scripts/check_arrow_visibility.py @@ -1,4 +1,5 @@ -#!/bin/bash -ex +#!/usr/bin/env python + # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information @@ -16,14 +17,21 @@ # specific language governing permissions and limitations # under the License. -nm -D -C /arrow-dist/lib64/libarrow.so > nm_arrow.log -grep ' T ' nm_arrow.log | grep -v arrow > visible_symbols.log +import subprocess + +exceptions = [ + '__once_proxy', +] -if [[ `cat visible_symbols.log | wc -l` -eq 2 ]] -then - exit 0 -fi +lines = subprocess.check_output(['nm', '-D', '-C', + '/arrow-dist/lib64/libarrow.so']) -cat visible_symbols.log +lines = lines.decode('ascii') +lines = lines.split('\n') +lines = [line for line in lines if ' T ' in line] +lines = [line for line in lines if 'arrow' not in line] +symbols = [line.split(' ')[2] for line in lines] +symbols = [symbol for symbol in symbols if symbol not in exceptions] -exit 1 +if len(symbols) != 2: + raise Exception(symbols) From e948e1a2fd8210d6d5e8f667b88a359ab65588e5 Mon Sep 17 00:00:00 2001 From: Robert Nishihara Date: Sat, 2 Jun 2018 17:41:42 -0700 Subject: [PATCH 03/12] Make visibility script executable. --- python/manylinux1/scripts/check_arrow_visibility.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 python/manylinux1/scripts/check_arrow_visibility.py diff --git a/python/manylinux1/scripts/check_arrow_visibility.py b/python/manylinux1/scripts/check_arrow_visibility.py old mode 100644 new mode 100755 From de3541df09bf9bb1f962a8b81c3ca2c269dc704c Mon Sep 17 00:00:00 2001 From: Robert Nishihara Date: Sat, 2 Jun 2018 17:58:59 -0700 Subject: [PATCH 04/12] Use Popen and communicate instead of check_output. --- python/manylinux1/scripts/check_arrow_visibility.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/python/manylinux1/scripts/check_arrow_visibility.py b/python/manylinux1/scripts/check_arrow_visibility.py index f34140e0b56..eba4dca7ab4 100755 --- a/python/manylinux1/scripts/check_arrow_visibility.py +++ b/python/manylinux1/scripts/check_arrow_visibility.py @@ -23,15 +23,16 @@ '__once_proxy', ] -lines = subprocess.check_output(['nm', '-D', '-C', - '/arrow-dist/lib64/libarrow.so']) - -lines = lines.decode('ascii') -lines = lines.split('\n') +process = subprocess.Popen(['nm', '-D', '-C', '/arrow-dist/lib64/libarrow.so'], + stdout=subprocess.PIPE) +stdout_data, _ = process.communicate() +stdout_data = stdout_data.decode('ascii') +lines = stdout_data.split('\n') lines = [line for line in lines if ' T ' in line] lines = [line for line in lines if 'arrow' not in line] symbols = [line.split(' ')[2] for line in lines] symbols = [symbol for symbol in symbols if symbol not in exceptions] +# TODO(rkn): We could just add '_fini' and '_init' to the exceptions list. if len(symbols) != 2: raise Exception(symbols) From 36bcd19b5dfdb7634eab62891a66c196498894b8 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Sun, 1 Jul 2018 18:22:20 -0400 Subject: [PATCH 05/12] Move to simplified symbols.map --- cpp/src/arrow/symbols.map | 57 +++++---------------------------------- 1 file changed, 7 insertions(+), 50 deletions(-) diff --git a/cpp/src/arrow/symbols.map b/cpp/src/arrow/symbols.map index 9faf38c9091..95417e40818 100644 --- a/cpp/src/arrow/symbols.map +++ b/cpp/src/arrow/symbols.map @@ -16,54 +16,11 @@ # under the License. { - # Symbols marked as 'local' are not exported by the DSO and thus may not - # be used by client applications. - local: - # devtoolset / static-libstdc++ symbols - __cxa_*; + global: + extern "C++" { + *arrow::*; + }; - # Static libraries that are linked in e.g. the manylinux1 build - # Brotli compression library - Brotli*; - # zlib - adler32*; - crc32*; - deflate*; - inflate*; - get_crc_table; - zcalloc; - zcfree; - zError; - zlibCompileFlags; - zlibVersion; - _tr_*; - # lz4 - LZ4_*; - # zstandard - ZSTD_*; - ZSTDv*; - HUF_*; - HUFv*; - FSE_*; - FSEv*; - ZBUFFv*; - ERR_getErrorString; - # jemalloc - je_arrow_*; - # ORC destructors - _ZThn8_N3orc*; - - extern "C++" { - # devtoolset or -static-libstdc++ - the Red Hat devtoolset statically - # links c++11 symbols into binaries so that the result may be executed on - # a system with an older libstdc++ which doesn't include the necessary - # c++11 symbols. - std::*; - - # Statically linked C++ dependencies - boost::*; - google::*; - orc::*; - snappy::*; - }; -}; + local: + *; +}; \ No newline at end of file From b29bdb6dbf31831b570235b7579e47989e8b5195 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Sun, 1 Jul 2018 18:30:09 -0400 Subject: [PATCH 06/12] Do not exclude any symbols from visibility check --- python/manylinux1/scripts/check_arrow_visibility.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/python/manylinux1/scripts/check_arrow_visibility.py b/python/manylinux1/scripts/check_arrow_visibility.py index eba4dca7ab4..143ad7c29e3 100755 --- a/python/manylinux1/scripts/check_arrow_visibility.py +++ b/python/manylinux1/scripts/check_arrow_visibility.py @@ -19,9 +19,7 @@ import subprocess -exceptions = [ - '__once_proxy', -] +exceptions = [] process = subprocess.Popen(['nm', '-D', '-C', '/arrow-dist/lib64/libarrow.so'], stdout=subprocess.PIPE) @@ -33,6 +31,5 @@ symbols = [line.split(' ')[2] for line in lines] symbols = [symbol for symbol in symbols if symbol not in exceptions] -# TODO(rkn): We could just add '_fini' and '_init' to the exceptions list. -if len(symbols) != 2: +if len(symbols) > 0: raise Exception(symbols) From 8302837b7d36c4e7074305ee781a8e8756bacbfb Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Sun, 1 Jul 2018 19:17:18 -0400 Subject: [PATCH 07/12] Link orc after protobuf otherwise protobuf symbols leak --- cpp/src/arrow/python/CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cpp/src/arrow/python/CMakeLists.txt b/cpp/src/arrow/python/CMakeLists.txt index a14ea962d77..75d9694991e 100644 --- a/cpp/src/arrow/python/CMakeLists.txt +++ b/cpp/src/arrow/python/CMakeLists.txt @@ -55,10 +55,17 @@ if (MSVC) ) endif() +if(NOT APPLE AND NOT MSVC) + # Localize thirdparty symbols using a linker version script. This hides them + # from the client application. The OS X linker does not support the + # version-script option. + set(ARROW_PYTHON_SHARED_LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/symbols.map") +endif() + ADD_ARROW_LIB(arrow_python SOURCES ${ARROW_PYTHON_SRCS} - SHARED_LINK_FLAGS "" - SHARED_LINK_LIBS ${ARROW_PYTHON_SHARED_LINK_LIBS} + SHARED_LINK_FLAGS ${ARROW_PYTHON_SHARED_LINK_FLAGS} + SHARED_PRIVATE_LINK_LIBS ${ARROW_PYTHON_SHARED_LINK_LIBS} STATIC_LINK_LIBS "${PYTHON_OTHER_LIBS}" ) From 424ec9d69796802f16cc667b85c76188c78d8215 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Sun, 1 Jul 2018 19:22:31 -0400 Subject: [PATCH 08/12] Add libarrow_python symbols visibility file --- cpp/src/arrow/python/symbols.map | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 cpp/src/arrow/python/symbols.map diff --git a/cpp/src/arrow/python/symbols.map b/cpp/src/arrow/python/symbols.map new file mode 100644 index 00000000000..137eb714316 --- /dev/null +++ b/cpp/src/arrow/python/symbols.map @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +{ + global: + extern "C++" { + *arrow::*; + }; + arrow_*; + pyarrow_*; + + local: + *; +}; \ No newline at end of file From 14791de553e7c9b00557fe1b147acc34dd536733 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Sun, 1 Jul 2018 21:36:20 -0400 Subject: [PATCH 09/12] Build wheel in one command --- python/manylinux1/build_arrow.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/manylinux1/build_arrow.sh b/python/manylinux1/build_arrow.sh index 95a649fba1d..cfb895bcf18 100755 --- a/python/manylinux1/build_arrow.sh +++ b/python/manylinux1/build_arrow.sh @@ -69,8 +69,7 @@ for PYTHON_TUPLE in ${PYTHON_VERSIONS}; do # Clear output directory rm -rf dist/ echo "=== (${PYTHON}) Building wheel ===" - PATH="$PATH:${CPYTHON_PATH}/bin" $PYTHON_INTERPRETER setup.py build_ext --inplace --with-parquet --bundle-arrow-cpp --bundle-boost --boost-namespace=arrow_boost - PATH="$PATH:${CPYTHON_PATH}/bin" $PYTHON_INTERPRETER setup.py bdist_wheel + PATH="$PATH:${CPYTHON_PATH}/bin" $PYTHON_INTERPRETER setup.py build_ext --inplace --with-parquet --bundle-arrow-cpp --bundle-boost --boost-namespace=arrow_boost bdist_wheel PATH="$PATH:${CPYTHON_PATH}/bin" $PYTHON_INTERPRETER setup.py sdist echo "=== (${PYTHON}) Test the existence of optional modules ===" From 9b9f44f2d5e33fa1358262c9241a9fe0aaab1582 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Mon, 2 Jul 2018 15:20:00 -0400 Subject: [PATCH 10/12] Try Antoine's workaround for static, revert broken manylinux1 build command Change-Id: I53818b506416bc87574514f1cc594c58ec20fb3e --- cpp/src/arrow/util/thread-pool-test.cc | 7 ++++--- cpp/src/arrow/util/thread-pool.cc | 20 ++++++++++++++------ cpp/src/arrow/util/thread-pool.h | 4 ++-- python/manylinux1/build_arrow.sh | 3 ++- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/cpp/src/arrow/util/thread-pool-test.cc b/cpp/src/arrow/util/thread-pool-test.cc index a70f0164e83..ec16c1f8b8d 100644 --- a/cpp/src/arrow/util/thread-pool-test.cc +++ b/cpp/src/arrow/util/thread-pool-test.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -125,10 +126,10 @@ class TestThreadPool : public ::testing::Test { fflush(stderr); } - std::shared_ptr MakeThreadPool() { return MakeThreadPool(4); } + std::unique_ptr MakeThreadPool() { return MakeThreadPool(4); } - std::shared_ptr MakeThreadPool(int threads) { - std::shared_ptr pool; + std::unique_ptr MakeThreadPool(int threads) { + std::unique_ptr pool; Status st = ThreadPool::Make(threads, &pool); return pool; } diff --git a/cpp/src/arrow/util/thread-pool.cc b/cpp/src/arrow/util/thread-pool.cc index 997ff5d743e..cfba5dca863 100644 --- a/cpp/src/arrow/util/thread-pool.cc +++ b/cpp/src/arrow/util/thread-pool.cc @@ -193,8 +193,8 @@ Status ThreadPool::SpawnReal(std::function task) { return Status::OK(); } -Status ThreadPool::Make(int threads, std::shared_ptr* out) { - auto pool = std::shared_ptr(new ThreadPool()); +Status ThreadPool::Make(int threads, std::unique_ptr* out) { + auto pool = std::unique_ptr(new ThreadPool()); RETURN_NOT_OK(pool->SetCapacity(threads)); *out = std::move(pool); return Status::OK(); @@ -240,8 +240,8 @@ int ThreadPool::DefaultCapacity() { } // Helper for the singleton pattern -std::shared_ptr ThreadPool::MakeCpuThreadPool() { - std::shared_ptr pool; +std::unique_ptr ThreadPool::MakeCpuThreadPool() { + std::unique_ptr pool; DCHECK_OK(ThreadPool::Make(ThreadPool::DefaultCapacity(), &pool)); // On Windows, the global ThreadPool destructor may be called after // non-main threads have been killed by the OS, and hang in a condition @@ -253,9 +253,17 @@ std::shared_ptr ThreadPool::MakeCpuThreadPool() { return pool; } +namespace { + std::mutex cpu_thread_pool_mutex; + std::unique_ptr cpu_thread_pool; +} + ThreadPool* GetCpuThreadPool() { - static std::shared_ptr singleton = ThreadPool::MakeCpuThreadPool(); - return singleton.get(); + std::lock_guard lock(cpu_thread_pool_mutex); + if (!cpu_thread_pool) { + cpu_thread_pool = ThreadPool::MakeCpuThreadPool(); + } + return cpu_thread_pool.get(); } } // namespace internal diff --git a/cpp/src/arrow/util/thread-pool.h b/cpp/src/arrow/util/thread-pool.h index c1b10f7d003..f42b04df809 100644 --- a/cpp/src/arrow/util/thread-pool.h +++ b/cpp/src/arrow/util/thread-pool.h @@ -67,7 +67,7 @@ struct packaged_task_wrapper { class ARROW_EXPORT ThreadPool { public: // Construct a thread pool with the given number of worker threads - static Status Make(int threads, std::shared_ptr* out); + static Status Make(int threads, std::unique_ptr* out); // Destroy thread pool; the pool will first be shut down ~ThreadPool(); @@ -146,7 +146,7 @@ class ARROW_EXPORT ThreadPool { static void WorkerLoop(std::shared_ptr state, std::list::iterator it); - static std::shared_ptr MakeCpuThreadPool(); + static std::unique_ptr MakeCpuThreadPool(); const std::shared_ptr sp_state_; State* const state_; diff --git a/python/manylinux1/build_arrow.sh b/python/manylinux1/build_arrow.sh index cfb895bcf18..95a649fba1d 100755 --- a/python/manylinux1/build_arrow.sh +++ b/python/manylinux1/build_arrow.sh @@ -69,7 +69,8 @@ for PYTHON_TUPLE in ${PYTHON_VERSIONS}; do # Clear output directory rm -rf dist/ echo "=== (${PYTHON}) Building wheel ===" - PATH="$PATH:${CPYTHON_PATH}/bin" $PYTHON_INTERPRETER setup.py build_ext --inplace --with-parquet --bundle-arrow-cpp --bundle-boost --boost-namespace=arrow_boost bdist_wheel + PATH="$PATH:${CPYTHON_PATH}/bin" $PYTHON_INTERPRETER setup.py build_ext --inplace --with-parquet --bundle-arrow-cpp --bundle-boost --boost-namespace=arrow_boost + PATH="$PATH:${CPYTHON_PATH}/bin" $PYTHON_INTERPRETER setup.py bdist_wheel PATH="$PATH:${CPYTHON_PATH}/bin" $PYTHON_INTERPRETER setup.py sdist echo "=== (${PYTHON}) Test the existence of optional modules ===" From c80469575ab9ef77ec71acbd4303fdbb50ef1fba Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Mon, 2 Jul 2018 17:20:20 -0400 Subject: [PATCH 11/12] Revert to static variable Change-Id: I99c29a98e248e31ab2b1356ba191715c96117161 --- cpp/src/arrow/symbols.map | 1 + cpp/src/arrow/util/thread-pool.cc | 12 ++---------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/cpp/src/arrow/symbols.map b/cpp/src/arrow/symbols.map index 95417e40818..0f6f072cd14 100644 --- a/cpp/src/arrow/symbols.map +++ b/cpp/src/arrow/symbols.map @@ -22,5 +22,6 @@ }; local: + __once_proxy; *; }; \ No newline at end of file diff --git a/cpp/src/arrow/util/thread-pool.cc b/cpp/src/arrow/util/thread-pool.cc index cfba5dca863..e05d639e490 100644 --- a/cpp/src/arrow/util/thread-pool.cc +++ b/cpp/src/arrow/util/thread-pool.cc @@ -253,17 +253,9 @@ std::unique_ptr ThreadPool::MakeCpuThreadPool() { return pool; } -namespace { - std::mutex cpu_thread_pool_mutex; - std::unique_ptr cpu_thread_pool; -} - ThreadPool* GetCpuThreadPool() { - std::lock_guard lock(cpu_thread_pool_mutex); - if (!cpu_thread_pool) { - cpu_thread_pool = ThreadPool::MakeCpuThreadPool(); - } - return cpu_thread_pool.get(); + static std::unique_ptr singleton = ThreadPool::MakeCpuThreadPool(); + return singleton.get(); } } // namespace internal From 68654baa997ee91d3c5a10feecb10284fa29e37f Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Mon, 2 Jul 2018 17:28:23 -0400 Subject: [PATCH 12/12] Revert unique_ptr->shared_ptr Change-Id: Iad094791792b5904214b9145c9e0e5acc4474c65 --- cpp/src/arrow/util/thread-pool-test.cc | 6 +++--- cpp/src/arrow/util/thread-pool.cc | 10 +++++----- cpp/src/arrow/util/thread-pool.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cpp/src/arrow/util/thread-pool-test.cc b/cpp/src/arrow/util/thread-pool-test.cc index ec16c1f8b8d..47859907676 100644 --- a/cpp/src/arrow/util/thread-pool-test.cc +++ b/cpp/src/arrow/util/thread-pool-test.cc @@ -126,10 +126,10 @@ class TestThreadPool : public ::testing::Test { fflush(stderr); } - std::unique_ptr MakeThreadPool() { return MakeThreadPool(4); } + std::shared_ptr MakeThreadPool() { return MakeThreadPool(4); } - std::unique_ptr MakeThreadPool(int threads) { - std::unique_ptr pool; + std::shared_ptr MakeThreadPool(int threads) { + std::shared_ptr pool; Status st = ThreadPool::Make(threads, &pool); return pool; } diff --git a/cpp/src/arrow/util/thread-pool.cc b/cpp/src/arrow/util/thread-pool.cc index e05d639e490..997ff5d743e 100644 --- a/cpp/src/arrow/util/thread-pool.cc +++ b/cpp/src/arrow/util/thread-pool.cc @@ -193,8 +193,8 @@ Status ThreadPool::SpawnReal(std::function task) { return Status::OK(); } -Status ThreadPool::Make(int threads, std::unique_ptr* out) { - auto pool = std::unique_ptr(new ThreadPool()); +Status ThreadPool::Make(int threads, std::shared_ptr* out) { + auto pool = std::shared_ptr(new ThreadPool()); RETURN_NOT_OK(pool->SetCapacity(threads)); *out = std::move(pool); return Status::OK(); @@ -240,8 +240,8 @@ int ThreadPool::DefaultCapacity() { } // Helper for the singleton pattern -std::unique_ptr ThreadPool::MakeCpuThreadPool() { - std::unique_ptr pool; +std::shared_ptr ThreadPool::MakeCpuThreadPool() { + std::shared_ptr pool; DCHECK_OK(ThreadPool::Make(ThreadPool::DefaultCapacity(), &pool)); // On Windows, the global ThreadPool destructor may be called after // non-main threads have been killed by the OS, and hang in a condition @@ -254,7 +254,7 @@ std::unique_ptr ThreadPool::MakeCpuThreadPool() { } ThreadPool* GetCpuThreadPool() { - static std::unique_ptr singleton = ThreadPool::MakeCpuThreadPool(); + static std::shared_ptr singleton = ThreadPool::MakeCpuThreadPool(); return singleton.get(); } diff --git a/cpp/src/arrow/util/thread-pool.h b/cpp/src/arrow/util/thread-pool.h index f42b04df809..c1b10f7d003 100644 --- a/cpp/src/arrow/util/thread-pool.h +++ b/cpp/src/arrow/util/thread-pool.h @@ -67,7 +67,7 @@ struct packaged_task_wrapper { class ARROW_EXPORT ThreadPool { public: // Construct a thread pool with the given number of worker threads - static Status Make(int threads, std::unique_ptr* out); + static Status Make(int threads, std::shared_ptr* out); // Destroy thread pool; the pool will first be shut down ~ThreadPool(); @@ -146,7 +146,7 @@ class ARROW_EXPORT ThreadPool { static void WorkerLoop(std::shared_ptr state, std::list::iterator it); - static std::unique_ptr MakeCpuThreadPool(); + static std::shared_ptr MakeCpuThreadPool(); const std::shared_ptr sp_state_; State* const state_;