summaryrefslogtreecommitdiff
path: root/jstests/aggregation/bugs/server17224.js
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2015-02-17 12:40:39 -0500
committerMathias Stearn <mathias@10gen.com>2015-03-05 13:22:19 -0500
commita0db9321139e8da657638ddbe7e86d8bac9ea3cc (patch)
tree07f2d51bcbf4985771463f697664525a55ab8b1e /jstests/aggregation/bugs/server17224.js
parentb2944efee1cf3b70da1dff3de14f09ea329da728 (diff)
downloadmongo-a0db9321139e8da657638ddbe7e86d8bac9ea3cc.tar.gz
SERVER-17224 Reserve room for EOO byte when starting BSONObj building
Since _done() is called from ~BSONObjBuilder we need to ensure that it cannot fail. This prevents a double exception leading to a std::terminate call. This also resolves SERVER-17226.
Diffstat (limited to 'jstests/aggregation/bugs/server17224.js')
-rw-r--r--jstests/aggregation/bugs/server17224.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/jstests/aggregation/bugs/server17224.js b/jstests/aggregation/bugs/server17224.js
new file mode 100644
index 00000000000..33042abab53
--- /dev/null
+++ b/jstests/aggregation/bugs/server17224.js
@@ -0,0 +1,24 @@
+// SERVER-17224 An aggregation result with exactly the right size could crash the server rather than
+// returning an error.
+(function() {
+ 'use strict';
+
+ var t = db.server17224;
+ t.drop();
+
+ // first 63MB
+ for (var i = 0; i < 63; i++) {
+ t.insert({a: new Array(1024 * 1024 + 1).join('a')});
+ }
+
+ // the remaining ~1MB with room for field names and other overhead
+ t.insert({a: new Array(1024 * 1024 - 1105).join('a')});
+
+ // do not use cursor form, since it has a different workaroud for this issue.
+ assert.commandFailed(
+ db.runCommand({aggregate: t.getName(),
+ pipeline: [{$match: {}}, {$group: {_id: null, arr: {$push: {a: '$a'}}}}]}));
+
+ // Make sure the server is still up.
+ assert.commandWorked(db.runCommand('ping'));
+}());