Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use extended alignment safe allocator in CPUThreadPoolExecutor
Summary: Until C++17 types with extended alignment need special handling in eg. std::vector and also std::unique_ptr. CPUThreadPoolExecutor has a default queue that requires extended alignment, but also allows the user to provide their own blocking queue. To handle this we move the private member to a shared_ptr which supported type erased destructors, and then use allocate_shared for the default queue type with a custom allocator that will satisfy alignment constraints. ``` .../unique_ptr.h:825:34: runtime error: constructor call on misaligned address 0x613000000040 for type 'folly::UnboundedBlockingQueue<folly::CPUThreadPoolExecutor::CPUTask>', which requires 128 byte alignment 0x613000000040: note: pointer points here 02 00 00 1c be be be be be be be be be be be be be be be be be be be be be be be be be be be be ^ #0 0x75b35e in std::_MakeUniq<folly::UnboundedBlockingQueue<folly::CPUThreadPoolExecutor::CPUTask> >::__single_object std::make_unique<folly::UnboundedBlockingQueue<folly::CPUThreadPoolExecutor::CPUTask> >() .../unique_ptr.h:825:30 #1 0x75602f in folly::CPUThreadPoolExecutor::CPUThreadPoolExecutor(unsigned long, std::shared_ptr<folly::ThreadFactory>) xplat/folly/executors/CPUThreadPoolExecutor.cpp:66:18 #2 0x756c6c in folly::CPUThreadPoolExecutor::CPUThreadPoolExecutor(unsigned long) xplat/folly/executors/CPUThreadPoolExecutor.cpp:84:7 ``` Differential Revision: D19237477 fbshipit-source-id: c88b26e2ca17e168f124ba27c0989f787b1ce4fd
- Loading branch information