[SERVER-4389] Wrong $eq format crashes Created: 29/Nov/11  Updated: 11/Jul/16  Resolved: 13/Jan/12

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

Type: Bug Priority: Major - P3
Reporter: Kristina Chodorow (Inactive) Assignee: Chris Westin
Resolution: Done Votes: 0
Labels: aggregation
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-447 new aggregation framework Closed
Duplicate
is duplicated by SERVER-4650 Malformed aggregation runCommand invo... Closed
Operating System: ALL
Participants:

 Description   

I used $eq:

{result:"1-0"}

instead of $eq:["result", "1-0"] and got:

Tue Nov 29 14:19:39 [conn1]  chess Assertion failure pPrefixedField[0] == '$' db/pipeline/expression.cpp 56
0x88d327 0x9091a7 0x911770 0xa0165a 0xa01b8c 0xa0205e 0xa01806 0xa023a1 0xa02119 0xa01806 0x9fc495 0x9e4464 0xca06b7 0xc7a617 0xc7b154 0xc7b643 0xc5c47a 0xc5d8bb 0xbde29d 0xbdef22 
 ./mongod(_ZN5mongo15printStackTraceERSo+0x27) [0x88d327]
 ./mongod(_ZN5mongo12sayDbContextEPKc+0x5e) [0x9091a7]
 ./mongod(_ZN5mongo8assertedEPKcS1_j+0x122) [0x911770]
 ./mongod(_ZN5mongo10Expression17removeFieldPrefixERKSs+0x4e) [0xa0165a]
 ./mongod(_ZN5mongo10Expression11parseObjectEPNS_11BSONElementEPNS0_9ObjectCtxE+0x4d4) [0xa01b8c]
 ./mongod(_ZN5mongo10Expression15parseExpressionEPKcPNS_11BSONElementE+0xec) [0xa0205e]
 ./mongod(_ZN5mongo10Expression11parseObjectEPNS_11BSONElementEPNS0_9ObjectCtxE+0x14e) [0xa01806]
 ./mongod(_ZN5mongo10Expression12parseOperandEPNS_11BSONElementE+0x139) [0xa023a1]
 ./mongod(_ZN5mongo10Expression15parseExpressionEPKcPNS_11BSONElementE+0x1a7) [0xa02119]
 ./mongod(_ZN5mongo10Expression11parseObjectEPNS_11BSONElementEPNS0_9ObjectCtxE+0x14e) [0xa01806]
 ./mongod(_ZN5mongo21DocumentSourceProject14createFromBsonEPNS_11BSONElementERKN5boost13intrusive_ptrINS_17ExpressionContextEEE+0x38b) [0x9fc495]
 ./mongod(_ZN5mongo8Pipeline12parseCommandERSsRNS_7BSONObjERKN5boost13intrusive_ptrINS_17ExpressionContextEEE+0x49c) [0x9e4464]
 ./mongod(_ZN5mongo15PipelineCommand3runERKSsRNS_7BSONObjEiRSsRNS_14BSONObjBuilderEb+0x7d) [0xca06b7]
 ./mongod(_ZN5mongo12_execCommandEPNS_7CommandERKSsRNS_7BSONObjEiRNS_14BSONObjBuilderEb+0x8e) [0xc7a617]
 ./mongod(_ZN5mongo11execCommandEPNS_7CommandERNS_6ClientEiPKcRNS_7BSONObjERNS_14BSONObjBuilderEb+0x896) [0xc7b154]
 ./mongod(_ZN5mongo12_runCommandsEPKcRNS_7BSONObjERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi+0x358) [0xc7b643]
 ./mongod(_ZN5mongo11runCommandsEPKcRNS_7BSONObjERNS_5CurOpERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi+0x46) [0xc5c47a]
 ./mongod(_ZN5mongo8runQueryERNS_7MessageERNS_12QueryMessageERNS_5CurOpES1_+0x223) [0xc5d8bb]
 ./mongod() [0xbde29d]
 ./mongod(_ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERKNS_11HostAndPortE+0x33f) [0xbdef22]
Tue Nov 29 14:19:39 [conn1] 

Full pipeline:

db.runCommand({aggregate: "fast_win", pipeline: [
...{
...   $project : {
...       win : {$cond : [
...           {$eq : {result : "1-0"}}, 1, 0
...       ]}
...   }
... }]})



 Comments   
Comment by Chris Westin [ 13/Jan/12 ]

This error message looks a lot better:

{
"errmsg" : "exception: the $eq operator requires an array of 2 operands"
,
"code" : 16019,
"ok" : 0
}

Comment by auto [ 13/Jan/12 ]

Author:

{u'login': u'cwestin', u'name': u'U-tellus\\cwestin', u'email': u'cwestin@10gen.com'}

Message: SERVER-4389
Branch: master
https://github.com/mongodb/mongo/commit/5df39dded95a978982ba9e2dab8c005cb1f88e7a

Comment by Chris Westin [ 13/Jan/12 ]

This doesn't crash anymore, but the error message is terrible:

{
"errmsg" : "exception: field path references must be prefixed with a '$'
(\"1-0\"",
"code" : 15982,
"ok" : 0
}

I'm going to take a look at detecting earlier, and getting something like "the $eq operator requires an array of two operands," or something similar.

Comment by Chris Westin [ 29/Nov/11 ]

I think that's because I haven't done proper error messages yet, but I'll check. I used assertions until I can merge with trunk and assign error numbers.

Generated at Thu Feb 08 03:05:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.