From 13df3441ae4df1313de213b3965fad60306cad21 Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Fri, 2 Sep 2016 19:25:47 -0700 Subject: [PATCH] Use MaxSizeVector instead of std::vector: xcode sometimes assumes that std::vector allocates aligned memory and therefore issues aligned instruction to initialize it. This can result in random crashes when compiling with AVX instructions enabled. --- unsupported/Eigen/CXX11/src/ThreadPool/EventCount.h | 4 ++-- .../Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/unsupported/Eigen/CXX11/src/ThreadPool/EventCount.h b/unsupported/Eigen/CXX11/src/ThreadPool/EventCount.h index 12b80d6c4..71d55552d 100644 --- a/unsupported/Eigen/CXX11/src/ThreadPool/EventCount.h +++ b/unsupported/Eigen/CXX11/src/ThreadPool/EventCount.h @@ -50,7 +50,7 @@ class EventCount { public: class Waiter; - EventCount(std::vector& waiters) : waiters_(waiters) { + EventCount(MaxSizeVector& waiters) : waiters_(waiters) { eigen_assert(waiters.size() < (1 << kWaiterBits) - 1); // Initialize epoch to something close to overflow to test overflow. state_ = kStackMask | (kEpochMask - kEpochInc * waiters.size() * 2); @@ -199,7 +199,7 @@ class EventCount { static const uint64_t kEpochMask = ((1ull << kEpochBits) - 1) << kEpochShift; static const uint64_t kEpochInc = 1ull << kEpochShift; std::atomic state_; - std::vector& waiters_; + MaxSizeVector& waiters_; void Park(Waiter* w) { std::unique_lock lock(w->mu); diff --git a/unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h b/unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h index 33ae45131..9f4e318e5 100644 --- a/unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h +++ b/unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h @@ -123,7 +123,7 @@ class NonBlockingThreadPoolTempl : public Eigen::ThreadPoolInterface { MaxSizeVector threads_; MaxSizeVector queues_; MaxSizeVector coprimes_; - std::vector waiters_; + MaxSizeVector waiters_; std::atomic blocked_; std::atomic spinning_; std::atomic done_;