[SERVER-27575] Segmentation fault when trying to use $bucketAuto with $max or $min operator in the output field Created: 04/Jan/17  Updated: 04/Jan/17  Resolved: 04/Jan/17

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 3.4.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Charles Sarrazin (Inactive) Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File segfault_bucketAuto_max.log    
Issue Links:
Duplicate
duplicates SERVER-25535 Remove injectExpressionContext() meth... Closed
Operating System: ALL
Steps To Reproduce:

var d = db.getSiblingDB('test');
 
d.drop();
d.foo.insertMany([
  { number_of_employees: 10 },
  { number_of_employees: 50 },
  { number_of_employees: 1 },
  { number_of_employees: 100 },
  { number_of_employees: 101 },
  { number_of_employees: 150 },
  { number_of_employees: 9203 },
  { number_of_employees: 100 },
  { number_of_employees: 1212 }
]);
 
d.foo.aggregate([
  {'$bucketAuto': {
    'groupBy': '$number_of_employees',
    'buckets': 3,
    'output': { 'value': { '$max': '$number_of_employees' } }
  }}
]);

Participants:

 Description   

It seems that using $max or $min in the output option of a $bucketAuto aggregation step triggers a segmentation fault. I managed to reproduce this issue with version 3.4.1-ent, and this script (replace $max by $min, to have the same behaviour):

var d = db.getSiblingDB('test');
 
d.drop();
d.foo.insertMany([
  { number_of_employees: 10 },
  { number_of_employees: 50 },
  { number_of_employees: 1 },
  { number_of_employees: 100 },
  { number_of_employees: 101 },
  { number_of_employees: 150 },
  { number_of_employees: 9203 },
  { number_of_employees: 100 },
  { number_of_employees: 1212 }
]);
 
d.foo.aggregate([
  {'$bucketAuto': {
    'groupBy': '$number_of_employees',
    'buckets': 3,
    'output': { 'value': { '$max': '$number_of_employees' } }
  }}
]);

Output:

2017-01-04T14:56:55.963+0100 E QUERY    [main] Error: error doing query: failed: network error while attempting to run command 'aggregate' on host '127.0.0.1:27017'  :
DB.prototype.runCommand@src/mongo/shell/db.js:132:1
DB.prototype.runReadCommand@src/mongo/shell/db.js:109:16
DBCollection.prototype._dbReadCommand@src/mongo/shell/collection.js:183:12
DBCollection.prototype.aggregate/doAgg<@src/mongo/shell/collection.js:1298:30
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1301:15
@(shell):1:1

The logs are attached to this ticket.



 Comments   
Comment by Charles Sarrazin (Inactive) [ 04/Jan/17 ]

Thanks anonymous.user!

Comment by Kelsey Schubert [ 04/Jan/17 ]

Hi charles.sarrazin,

This issue will be corrected with the release of MongoDB 3.4.2. Please see SERVER-25535 for more details.

Thank you,
Thomas

Generated at Thu Feb 08 04:15:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.