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

FindAndModifyCommand::run can create an invalid StatusWith

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.4
    • Affects Version/s: None
    • Component/s: Internal Code, Querying
    • Fully Compatible
    • ALL
    • Hide

      Pull https://github.com/amidvidy/mongo/tree/SERVER-18007-optional and run any of find_and_modify

      {"", 2, 3, 4}

      .js

      Show
      Pull https://github.com/amidvidy/mongo/tree/SERVER-18007-optional and run any of find_and_modify {"", 2, 3, 4} .js
    • Platform 4 06/05/15

      StatusWith<WriteConcernOptions> wcResult = extractWriteConcern(cmdObj);
      ... lots of lines of code...
      WriteConcernResult res;
      wcResult = waitForWriteConcern(
                          txn,
                          repl::ReplClientInfo::forClient(txn->getClient()).getLastOp(),
                          &res);
      appendCommandWCStatus(result, wcResult.getStatus());
      

      Note that waitForWriteConcern returns a Status, not a StatusWith. If it succeeds, Status::OK() is assigned to wcResult which creates an invalid StatusWith. An engaged StatusWith<T> (i.e. a StatusWith<T> s, such that s.isOK() == true) can only be created by assigning a T - assigning Status::OK() does not actually initialize the value.

            Assignee:
            adam.midvidy Adam Midvidy
            Reporter:
            adam.midvidy Adam Midvidy
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: