[SERVER-51337] use-after-move in NetworkInterfaceMock Created: 03/Oct/20  Updated: 29/Oct/23  Resolved: 05/Oct/20

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.9.0, 4.4.4

Type: Bug Priority: Major - P3
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Problem/Incident
is caused by SERVER-39513 NetworkInterface::setAlarm should be ... Closed
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.4
Sprint: Service arch 2020-10-19
Participants:
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.



 Comments   
Comment by Ian Whalen (Inactive) [ 04/Jan/21 ]

Author:

{'username': u'evrg-bot-webhook', 'name': u'Billy Donahue', 'email': u'billy.donahue@mongodb.com'}

Message:SERVER-51337 fix use-after-move in NetworkInterfaceMock

(cherry picked from commit 5a155f06bffb6141a40497fdef1dd61a2aaf2962)
Branch:v4.4
https://github.com/mongodb/mongo/commit/7c8e5d2492949658297e4def62c0428823585cd1

Comment by Billy Donahue [ 19/Dec/20 ]

Githook didn't trigger on the backport commit. Manually entering it:

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-51337 fix use-after-move in NetworkInterfaceMock
Branch: v4.4
https://github.com/mongodb/mongo/commit/7c8e5d2492949658297e4def62c0428823585cd1

Comment by Billy Donahue [ 18/Dec/20 ]

Backport to 4.4 requested as it might fix BF-18045

Comment by Billy Donahue [ 18/Dec/20 ]

Possibly related to BF-18045 4.4, windows debug.

Comment by Githook User [ 05/Oct/20 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-51337 fix use-after-move in NetworkInterfaceMock
Branch: master
https://github.com/mongodb/mongo/commit/5a155f06bffb6141a40497fdef1dd61a2aaf2962

Generated at Thu Feb 08 05:25:12 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.