Fix JemallocNodumpAllocator extent_hooks API.
authorQi Wang <qiwang@fb.com>
Fri, 2 Jun 2017 19:32:01 +0000 (12:32 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 2 Jun 2017 19:36:53 +0000 (12:36 -0700)
Summary: Using extent_hooks mallctl to update hooks.

Reviewed By: jasone

Differential Revision: D5174623

fbshipit-source-id: 9313ee9ae55c85d973736077727e54a5825f4c3d

folly/experimental/JemallocNodumpAllocator.cpp
folly/experimental/JemallocNodumpAllocator.h

index e2ce6d8..8d29dbc 100644 (file)
@@ -89,7 +89,12 @@ bool JemallocNodumpAllocator::extend_and_setup_arena() {
   }
 
   // Set the custom hook
-  hooks->alloc = &JemallocNodumpAllocator::alloc;
+  extent_hooks_ = *hooks;
+  extent_hooks_.alloc = &JemallocNodumpAllocator::alloc;
+  if (auto ret =
+          mallctl(key.c_str(), nullptr, nullptr, &hooks, sizeof(hooks))) {
+    LOG(FATAL) << "Unable to set the hooks: " << errnoStr(ret);
+  }
 #endif
 
   return true;
index 487a06b..a87161f 100644 (file)
@@ -91,6 +91,7 @@ class JemallocNodumpAllocator {
   static void* alloc(
       void* chunk,
 #else
+  extent_hooks_t extent_hooks_;
   static extent_alloc_t* original_alloc_;
   static void* alloc(
       extent_hooks_t* extent,