summaryrefslogtreecommitdiff
path: root/src/mongo/platform/stack_locator_solaris.cpp
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2015-10-26 13:01:53 -0400
committerAndrew Morrow <acm@mongodb.com>2015-10-27 08:06:42 -0400
commite556e4763ad88c3308347b56b4831c46b014627e (patch)
tree31eb5f821d77b50a7d7185ef571d3824dfea0d03 /src/mongo/platform/stack_locator_solaris.cpp
parent17a0b2a3be87fb1a1a86db2ee0bf1871e4b8d6fc (diff)
downloadmongo-e556e4763ad88c3308347b56b4831c46b014627e.tar.gz
SERVER-19614 Implement stack bounds detection
Diffstat (limited to 'src/mongo/platform/stack_locator_solaris.cpp')
-rw-r--r--src/mongo/platform/stack_locator_solaris.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/mongo/platform/stack_locator_solaris.cpp b/src/mongo/platform/stack_locator_solaris.cpp
new file mode 100644
index 00000000000..055f25505ba
--- /dev/null
+++ b/src/mongo/platform/stack_locator_solaris.cpp
@@ -0,0 +1,51 @@
+/**
+ * Copyright (C) 2015 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/platform/stack_locator.h"
+
+#include <thread.h>
+
+#include "mongo/util/assert_util.h"
+
+namespace mongo {
+
+StackLocator::StackLocator() {
+ stack_t stack;
+ invariant(thr_stksegment(&stack) == 0);
+
+ invariant(stack.ss_sp != nullptr);
+ invariant(stack.ss_size != 0);
+
+ // TODO: Assumes stack grows downward on Solaris
+ _begin = stack.ss_sp;
+ _end = static_cast<char*>(_begin) - stack.ss_size;
+}
+
+} // namespace mongo