Repository: mesos
Updated Branches:
  refs/heads/master 5c0f70d4f -> 89d072d85


Removed capturing 'this' in sandbox authorization.

Previously we captured 'this' in the lambda. As we store the lamda in
the FilesProcess accessing 'this' can lead to segmentation faults.
The problem here is that the 'Framework' might go out of scope and
hence 'this' might be a dangling pointer.

Review: https://reviews.apache.org/r/48849/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/89d072d8
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/89d072d8
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/89d072d8

Branch: refs/heads/master
Commit: 89d072d8567ccdcf11d1b1093350f393885fc593
Parents: 5c0f70d
Author: Joerg Schad <jo...@mesosphere.io>
Authored: Fri Jun 17 17:45:36 2016 +0200
Committer: Till Toenshoff <toensh...@me.com>
Committed: Fri Jun 17 17:45:36 2016 +0200

----------------------------------------------------------------------
 src/slave/slave.cpp | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/89d072d8/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index f46fc01..4bf01f2 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -776,8 +776,13 @@ void Slave::initialize()
           return http.containers(request, principal);
         });
 
-  auto authorize = [this](const Option<string>& principal) {
-    return authorizeLogAccess(principal);
+  const PID<Slave> slavePid = self();
+
+  auto authorize = [slavePid](const Option<string>& principal) {
+    return dispatch(
+        slavePid,
+        &Slave::authorizeLogAccess,
+        principal);
   };
 
   // Expose the log file for the webui. Fall back to 'log_dir' if
@@ -5734,10 +5739,12 @@ Executor* Framework::launchExecutor(
   ExecutorID executorId = executorInfo.executor_id();
   FrameworkID frameworkId = id();
 
+  const PID<Slave> slavePid = slave->self();
+
   auto authorize =
-    [this, executorId, frameworkId](const Option<string>& principal) {
+    [slavePid, executorId, frameworkId](const Option<string>& principal) {
       return dispatch(
-          slave,
+          slavePid,
           &Slave::authorizeSandboxAccess,
           principal,
           frameworkId,
@@ -5936,10 +5943,12 @@ void Framework::recoverExecutor(const ExecutorState& 
state)
   ExecutorID executorId = state.id;
   FrameworkID frameworkId = id();
 
+  const PID<Slave> slavePid = slave->self();
+
   auto authorize =
-    [this, executorId, frameworkId](const Option<string>& principal) {
+    [slavePid, executorId, frameworkId](const Option<string>& principal) {
       return dispatch(
-          slave,
+          slavePid,
           &Slave::authorizeSandboxAccess,
           principal,
           frameworkId,

Reply via email to