Commit 55791684 authored by Giuseppe Ottaviano's avatar Giuseppe Ottaviano Committed by Facebook Github Bot

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
parent 03c1142d
......@@ -29,6 +29,7 @@
#include <vector>
#include <folly/Hash.h>
#include <folly/Indestructible.h>
#include <folly/Likely.h>
#include <folly/Memory.h>
#include <folly/Portability.h>
......@@ -492,8 +493,10 @@ class CoreAllocator {
template <size_t Stripes>
typename CoreAllocator<Stripes>::Allocator* getCoreAllocator(size_t stripe) {
static CoreAllocator<Stripes> 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<CoreAllocator<Stripes>> allocator;
return allocator->get(stripe);
}
template <typename T, size_t Stripes>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment