You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2015/09/22 00:04:33 UTC

mesos git commit: Allocated the stack used by clone dynamically.

Repository: mesos
Updated Branches:
  refs/heads/master a2e740d36 -> 57361f10c


Allocated the stack used by clone dynamically.

This is to address the issue when running multiple slaves during tests.
The glibc 'clone' will modify the stack passed to it, therefore we
cannot use a shared stack.

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


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

Branch: refs/heads/master
Commit: 57361f10ccf1e026dbb691e67277cb0cb71c8ea6
Parents: a2e740d
Author: haosdent huang <ha...@gmail.com>
Authored: Mon Sep 21 14:27:34 2015 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Sep 21 15:03:50 2015 -0700

----------------------------------------------------------------------
 src/slave/containerizer/linux_launcher.cpp | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/57361f10/src/slave/containerizer/linux_launcher.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/linux_launcher.cpp b/src/slave/containerizer/linux_launcher.cpp
index dde552f..fd0ffcf 100644
--- a/src/slave/containerizer/linux_launcher.cpp
+++ b/src/slave/containerizer/linux_launcher.cpp
@@ -181,7 +181,15 @@ static pid_t clone(
   // - unsigned long long used for best alignment.
   // - static is ok because each child gets their own copy after the clone.
   // - 8 MiB appears to be the default for "ulimit -s" on OSX and Linux.
-  static unsigned long long stack[(8*1024*1024)/sizeof(unsigned long long)];
+  //
+  // NOTE: We need to allocate the stack dynamically. This is because
+  // glibc's 'clone' will modify the stack passed to it, therefore the
+  // stack must NOT be shared as multiple 'clone's can be invoked
+  // simultaneously.
+  int stackSize = 8 * 1024 * 1024;
+
+  unsigned long long *stack =
+    new unsigned long long[stackSize/sizeof(unsigned long long)];
 
   int flags = namespaces.isSome() ? namespaces.get() : 0;
   flags |= SIGCHLD; // Specify SIGCHLD as child termination signal.
@@ -189,11 +197,15 @@ static pid_t clone(
   LOG(INFO) << "Cloning child process with flags = "
             << ns::stringify(flags);
 
-  return ::clone(
+  pid_t pid = ::clone(
       childMain,
-      &stack[sizeof(stack)/sizeof(stack[0]) - 1],  // stack grows down.
+      &stack[stackSize/sizeof(stack[0]) - 1],  // stack grows down.
       flags,
       (void*) &func);
+
+  delete[] stack;
+
+  return pid;
 }