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

use-after-move in NetworkInterfaceMock

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.9.0, 4.4.4
    • Component/s: Internal Code
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v4.4
    • Sprint:
      Service arch 2020-10-19
    • Linked BF Score:
      16

      Description

      The first cbh argument here has an indeterminate value, as evaluation order of function arguments is unspecified. If argument 3 is evaluated first, the lambda will move from the cbh variable to bind its captured copy of it, leaving an empty value for argument 1. cbh is an object of a class that wraps a std::shared_ptr.

      https://github.com/mongodb/mongo/blob/56e98fd598daf638cafd45a9b74c4b0bd0792916/src/mongo/executor/network_interface_mock.cpp#L484

       
              _alarms.emplace(cbh,
                              _now_inlock() + timeout,
                              [this,
                               cbh = std::move(cbh),
                               queuesToCheck = std::move(queuesToCheck),
                               rs = std::move(rs)](Status) {
                                  _interruptWithResponse_inlock(cbh, queuesToCheck, rs);
                              });
      
      

      This may or may not be a contributor to BF-18045.
      Bug was introduced as part of SERVER-39513, which added the cbh argument to the AlarmInfo constructor.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              billy.donahue Billy Donahue
              Reporter:
              billy.donahue Billy Donahue
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: