From 55791684950381d92cef305d1e9124120b178ad5 Mon Sep 17 00:00:00 2001 From: Giuseppe Ottaviano Date: Tue, 6 Jun 2017 17:32:12 -0700 Subject: [PATCH] Fix destruction order problem in getCoreAllocator Summary: We cannot guarantee the correct destruction order of the Meyers singleton owning the allocator, and the objects allocated with it, so we just leak it using `Indestructible`. Reviewed By: djwatson Differential Revision: D5196227 fbshipit-source-id: ec07ab1e21af7814194883b252d45aa36d2a04b1 --- folly/detail/CacheLocality.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/folly/detail/CacheLocality.h b/folly/detail/CacheLocality.h index b6dd66e7..b7aa2553 100644 --- a/folly/detail/CacheLocality.h +++ b/folly/detail/CacheLocality.h @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -492,8 +493,10 @@ class CoreAllocator { template typename CoreAllocator::Allocator* getCoreAllocator(size_t stripe) { - static CoreAllocator allocator; - return allocator.get(stripe); + // We cannot make sure that the allocator will be destroyed after + // all the objects allocated with it, so we leak it. + static Indestructible> allocator; + return allocator->get(stripe); } template -- 2.34.1