summaryrefslogtreecommitdiff
path: root/src/mongo/scripting
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2018-11-19 12:04:22 -0500
committerMark Benvenuto <mark.benvenuto@mongodb.com>2018-12-20 16:09:49 -0500
commit6e295dacd63466f0bbad2582e2a0ae683a91ebe8 (patch)
treece7ca27b2b22c91cbfdfadba46e82b3c115f6410 /src/mongo/scripting
parent80f4777ad3442351a55d839a25907e98c6fbd2ae (diff)
downloadmongo-6e295dacd63466f0bbad2582e2a0ae683a91ebe8.tar.gz
SERVER-36740 Sometimes crashes on windows don't provide a backtrace
(cherry picked from commit f5b4471bc5d0bee53474456761417222ddd4654e)
Diffstat (limited to 'src/mongo/scripting')
-rw-r--r--src/mongo/scripting/mozjs/implscope.cpp12
-rw-r--r--src/mongo/scripting/mozjs/implscope.h2
2 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/scripting/mozjs/implscope.cpp b/src/mongo/scripting/mozjs/implscope.cpp
index bbadc79d1cf..dae150f2e6c 100644
--- a/src/mongo/scripting/mozjs/implscope.cpp
+++ b/src/mongo/scripting/mozjs/implscope.cpp
@@ -122,6 +122,14 @@ struct MozJSImplScope::MozJSEntry {
void MozJSImplScope::_reportError(JSContext* cx, const char* message, JSErrorReport* report) {
auto scope = getScope(cx);
+ // If we are recursively calling _reportError because of ReportOverRecursed, lets just quit now
+ if (scope->_inReportError) {
+ return;
+ }
+
+ scope->_inReportError = true;
+ const auto guard = MakeGuard([&] { scope->_inReportError = false; });
+
if (!JSREPORT_IS_WARNING(report->flags)) {
std::string exceptionMsg;
@@ -395,6 +403,9 @@ MozJSImplScope::MozRuntime::MozRuntime(const MozJSScriptEngine* engine) {
// stored on the stack which increases the stack pressure. It does not affects non-debug
// builds.
const decltype(available_stack_space) reserve_stack_space = 96 * 1024;
+#elif defined(_WIN32)
+ // Windows is greedy for stack space while processing exceptions.
+ const decltype(available_stack_space) reserve_stack_space = 96 * 1024;
#else
const decltype(available_stack_space) reserve_stack_space = 64 * 1024;
#endif
@@ -434,6 +445,7 @@ MozJSImplScope::MozJSImplScope(MozJSScriptEngine* engine)
_generation(0),
_requireOwnedObjects(false),
_hasOutOfMemoryException(false),
+ _inReportError(false),
_binDataProto(_context),
_bsonProto(_context),
_codeProto(_context),
diff --git a/src/mongo/scripting/mozjs/implscope.h b/src/mongo/scripting/mozjs/implscope.h
index e01a414e403..79f83fb4aff 100644
--- a/src/mongo/scripting/mozjs/implscope.h
+++ b/src/mongo/scripting/mozjs/implscope.h
@@ -438,6 +438,8 @@ private:
bool _requireOwnedObjects;
bool _hasOutOfMemoryException;
+ bool _inReportError;
+
WrapType<BinDataInfo> _binDataProto;
WrapType<BSONInfo> _bsonProto;
WrapType<CodeInfo> _codeProto;