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

use-after-move in NetworkInterfaceMock

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.9.0, 4.4.4
    • Affects Version/s: None
    • Component/s: Internal Code
    • None
    • Fully Compatible
    • ALL
    • v4.4
    • Service arch 2020-10-19
    • 16

      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.

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

              Created:
              Updated:
              Resolved: