The main entry methods in the query subsystem transfer ownership of heap-allocated objects through raw pointers, which is error-prone. These methods should use std::unique_ptr instead. Partial list follows:
- CanonicalQuery::canonicalize(). Caller receives ownership of a CanonicalQuery.
- LiteParsedQuery::make(). Caller receives ownership of a LiteParsedQuery.
- StatusWithMatchExpression replace MatchExpression* with unique_ptr<MatchExpression>
- MatchExpression::shallowClone(). Caller receives ownership of a MatchExpression.
- PlanExecutor::make(). Caller releases ownership of a WorkingSet, a PlanStage, a CanonicalQuery and a QuerySolution, and receives ownership of a PlanExecutor.
- getExecutor(). Caller releases ownership of a CanonicalQuery, and receives ownership of a PlanExecutor (other public methods in get_executor.cpp can follow suit).
- PlanExecutor::getStats(). Caller receives ownership of a PlanStageStats.
Linking a few tickets describing ownership-related memory leaks induced by incorrect use of the above (and related) methods.
- depends on
-
SERVER-16559 Require C++11 when building the server
- Closed
- is duplicated by
-
SERVER-18068 Coverity analysis defect 72413: Resource leak
- Closed
- is related to
-
SERVER-14892 Invalid {$elemMatch: {$where}} query causes memory leak
- Closed
-
SERVER-17901 Memory leak in IndexCatalog::_isSpecOk()
- Closed
-
SERVER-19040 WhereMatchExpression::shallowClone can leak memory during interruption
- Closed
- related to
-
SERVER-14747 memory leak in the MultiPlanStage
- Closed
-
SERVER-15485 CanonicalQuery::canonicalize can leak a LiteParsedQuery
- Closed
-
SERVER-15639 Text queries can return incorrect results and leak memory when multiple predicates given on same text index prefix field
- Closed
-
SERVER-15758 Memory leak when running find_dedup.js test
- Closed
-
SERVER-16035 Leaks emanating from QueryPlannerAccess::makeCollectionScan
- Closed