diff options
author | Ben Becker <ben.becker@10gen.com> | 2012-12-16 10:43:40 -0800 |
---|---|---|
committer | Ben Becker <ben.becker@10gen.com> | 2012-12-16 10:43:40 -0800 |
commit | e21d8122f4613756c018b0140f191bf0c6ab3c34 (patch) | |
tree | d1155eb82e581ced61582ec493196058e3ac1fda /src/mongo/util/stacktrace.cpp | |
parent | eb8407e4cccaae93a869719c4d9d13e8f84dc92d (diff) | |
download | mongo-e21d8122f4613756c018b0140f191bf0c6ab3c34.tar.gz |
SERVER-7872: check retval of backtrace_symbols
Diffstat (limited to 'src/mongo/util/stacktrace.cpp')
-rw-r--r-- | src/mongo/util/stacktrace.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/mongo/util/stacktrace.cpp b/src/mongo/util/stacktrace.cpp index 7858eef82e6..1926cd48c3b 100644 --- a/src/mongo/util/stacktrace.cpp +++ b/src/mongo/util/stacktrace.cpp @@ -8,6 +8,8 @@ #include <map> #include <vector> +#include "mongo/util/log.h" + #ifdef _WIN32 #include <sstream> #include <stdio.h> @@ -16,7 +18,6 @@ #include "mongo/platform/windows_basic.h" #include <DbgHelp.h> #include "mongo/util/assert_util.h" -#include "mongo/util/log.h" #endif #ifdef MONGO_HAVE_EXECINFO_BACKTRACE @@ -43,6 +44,12 @@ namespace mongo { char **strings; strings = ::backtrace_symbols( b, size ); + if (strings == NULL) { + const int err = errno; + os << "Unable to collect backtrace symbols (" << errnoWithDescription(err) << ")" + << std::endl; + return; + } for ( int i = 0; i < size; i++ ) os << ' ' << strings[i] << '\n'; os.flush(); |