Collection cloner with function_ref has memory bug

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Replication
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      We have this piece of code in collection_cloner.cpp:

              CollectionBulkLoader::ParseRecordIdAndDocFunc fn = (_recordIdsReplicated)
                  ? ([](const BSONObj& doc) {
                        return std::make_pair(RecordId(doc["r"].Long()), doc["d"].Obj());
                    })
                  : ([](const BSONObj& doc) { return std::make_pair(RecordId(0), doc); });
      

      This is problematic as described in SERVER-121669, because the temporary that the function_ref is bound to is destroyed right after that line.

            Assignee:
            Vishnu Kaushik
            Reporter:
            Vishnu Kaushik
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: