Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
SERVER-19614 Use stack bounds to limit JS recursion
- Loading branch information
Showing
2 changed files
with
55 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,41 @@ | ||
// Basic tests for a form of stack recursion that's been shown to cause C++ | ||
// side stack overflows in the past. See SERVER-19614. | ||
|
||
// TODO: Re-enable this test once SERVER-19614 has been resolved in a | ||
// way that does not conflict with SERVER-20678. See the similar | ||
// comment in src/mongo/scripting/mozjs/implscope.cpp for additional | ||
// details. | ||
// | ||
// (function () { | ||
// "use strict"; | ||
// | ||
// db.recursion.drop(); | ||
// | ||
// // Make sure the shell doesn't blow up | ||
// function shellRecursion() { | ||
// shellRecursion.apply(); | ||
// } | ||
// assert.throws(shellRecursion); | ||
// | ||
// // Make sure db.eval doesn't blow up | ||
// function dbEvalRecursion() { | ||
// db.eval(function () { | ||
// function recursion() { | ||
// recursion.apply(); | ||
// } | ||
// recursion(); | ||
// }); | ||
// } | ||
// assert.commandFailedWithCode(assert.throws(dbEvalRecursion), ErrorCodes.JSInterpreterFailure); | ||
// | ||
// // Make sure mapReduce doesn't blow up | ||
// function mapReduceRecursion() { | ||
// db.recursion.mapReduce(function(){ | ||
// (function recursion(){ | ||
// recursion.apply(); | ||
// })(); | ||
// }, function(){ | ||
// }, { | ||
// out: 'inline' | ||
// }); | ||
// } | ||
// | ||
// db.recursion.insert({}); | ||
// assert.commandFailedWithCode( | ||
// assert.throws(mapReduceRecursion), ErrorCodes.JSInterpreterFailure); | ||
// }()); | ||
(function () { | ||
"use strict"; | ||
|
||
db.recursion.drop(); | ||
|
||
// Make sure the shell doesn't blow up | ||
function shellRecursion() { | ||
shellRecursion.apply(); | ||
} | ||
assert.throws(shellRecursion); | ||
|
||
// Make sure db.eval doesn't blow up | ||
function dbEvalRecursion() { | ||
db.eval(function () { | ||
function recursion() { | ||
recursion.apply(); | ||
} | ||
recursion(); | ||
}); | ||
} | ||
assert.commandFailedWithCode(assert.throws(dbEvalRecursion), ErrorCodes.JSInterpreterFailure); | ||
|
||
// Make sure mapReduce doesn't blow up | ||
function mapReduceRecursion() { | ||
db.recursion.mapReduce(function(){ | ||
(function recursion(){ | ||
recursion.apply(); | ||
})(); | ||
}, function(){ | ||
}, { | ||
out: 'inline' | ||
}); | ||
} | ||
|
||
db.recursion.insert({}); | ||
assert.commandFailedWithCode( | ||
assert.throws(mapReduceRecursion), ErrorCodes.JSInterpreterFailure); | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters