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 e2ce6d8c5061c48ff5fd6ebd73d2322618b778be..8d29dbc82109e2c87f00ccda5a781ff4cddda9a3 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 487a06b98a90a59adb42ab457429c86cac8c14c9..a87161f02dac9af95420bb4241a6f6fa4140f91c 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,