You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2016/04/25 23:32:17 UTC

[24/50] mesos git commit: Fixed a pointer ownership bug in Master::removeFramework.

Fixed a pointer ownership bug in Master::removeFramework.

Previously, the framework being removed was pushed back to the circular
buffer of completed frameworks as a shared_ptr halfway through the
computation done to remove a framework from the master. The pointer to
the framework was then accessed again after this point.

Pushing a shared_ptr this way is fine so long as the push_pack succeeds
and the pointer is actually inserted into the buffer. However, with the
introduction of the new flags to set the size of this buffer via
max_completed_frameworks, it's possible for the size of this buffer to
be 0. As such, the circular buffer was taking control of the pointer,
noticing there was nowhere to push it, and then freeing it.  This causes
problems since the pointer is then accessed later on.

This patch moves the insertion of the shared pointer into the circular
buffer to the end of the removeFramework() call. This change should not
have any adverse effects.

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


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

Branch: refs/heads/0.26.x
Commit: 8137265184cd24c5fdfe7079d60fe49292dab394
Parents: 0de9b57
Author: Kevin Klues <kl...@gmail.com>
Authored: Mon Jan 11 17:23:52 2016 -0800
Committer: Michael Park <mp...@apache.org>
Committed: Fri Feb 26 20:59:06 2016 -0800

----------------------------------------------------------------------
 src/master/master.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/81372651/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 7bac0fe..d02ccef 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -5656,9 +5656,6 @@ void Master::removeFramework(Framework* framework)
 
   framework->unregisteredTime = Clock::now();
 
-  // The completedFramework buffer now owns the framework pointer.
-  frameworks.completed.push_back(shared_ptr<Framework>(framework));
-
   CHECK(roles.contains(framework->info.role()))
     << "Unknown role " << framework->info.role()
     << " of framework " << *framework;
@@ -5687,6 +5684,9 @@ void Master::removeFramework(Framework* framework)
   // Remove the framework.
   frameworks.registered.erase(framework->id());
   allocator->removeFramework(framework->id());
+
+  // The completedFramework buffer now owns the framework pointer.
+  frameworks.completed.push_back(shared_ptr<Framework>(framework));
 }