From: Giuseppe Ottaviano Date: Wed, 7 Jun 2017 00:32:12 +0000 (-0700) Subject: Fix destruction order problem in getCoreAllocator X-Git-Tag: v2017.06.12.00~26 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=55791684950381d92cef305d1e9124120b178ad5 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 --- 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