[SERVER-6462] stack overflow when comparing deeply nested bson objects Created: 16/Jul/12  Updated: 06/Dec/22  Resolved: 14/Nov/16

Status: Closed
Project: Core Server
Component/s: Index Maintenance, Security, Stability
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Aaron Staple Assignee: Backlog - Query Team (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-6251 mongod 2.1.2 crashes when indexing de... Closed
is depended on by SERVER-6448 illegal instruction following deep re... Closed
Duplicate
is duplicated by SERVER-6448 illegal instruction following deep re... Closed
Related
is related to SERVER-8433 Aggregating deeply-nested documents c... Closed
Assigned Teams:
Query
Operating System: ALL
Participants:

 Description   

Observed behavior: When mongod compares two deeply nested objects, a stack overflow is triggered. The following example triggers a stack overflow on osx 10.7.4 with both debug and release builds:

t = db.t;
t.drop();
 
function makeNestObj(depth){
    toret = { a : 1};
 
    for(i = 1; i < depth; i++){
        toret = {a : toret};
    }
 
    return toret;
}
 
nestedObj = makeNestObj(1500);
 
// Save two deeply recursive 'a' values, so we can sort them.                               
t.insert( { a:nestedObj }, true );
t.insert( { a:nestedObj }, true );
 
t.find().sort( { a:1 } ).itcount(); // In memory sort triggers a stack overflow.
 
t.ensureIndex( { a:1 } ); // External sorter triggers a stack overflow.                     



 Comments   
Comment by Eric Milkie [ 14/Nov/16 ]

Recursion depth limit of 150 prevents this crash now.

Comment by Andy Schwerin [ 08/Mar/13 ]

alerner, moving this to indexing because it's about the behavior of woCompare on unusual (highly nested) documents. Can you triage?

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