Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-16889

Query subsystem public API should use std::unique_ptr for ownership transfer

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.6
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Fully Compatible
    • Quint Iteration 6

      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.

            Assignee:
            qingyang.chen Qingyang Chen
            Reporter:
            rassi J Rassi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: