-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Replication
-
ALL
-
None
-
None
-
None
-
None
-
None
-
None
-
None
In src/mongo/client/replica_set_monitor_manager.h, class ReplicaSetMonitorManager has a default constructor ReplicaSetMonitorManager() = default; which does not initialize the _numMonitorsCreated member (an int), which has no default member initializer, so a default-constructed instance holds an indeterminate _numMonitorsCreated. This member is likely used for tracking the number of created monitors, and reading the uninitialized value constitutes undefined behavior, potentially leading to incorrect monitoring behavior or crashes if the value is accessed before being explicitly set.
Found by static analysis (Svace, UNINIT.CTOR): "Constructor declared at replica_set_monitor_manager.h:118 may not initialize class members of 'mongo::ReplicaSetMonitorManager'. Following members aren't initialized: _numMonitorsCreated."
The fix is to add a default member initializer (int _numMonitorsCreated = 0
or initialize it explicitly in the constructor.
- is related to
-
SERVER-130952 BSONColumn::Iterator::DecodingState::Decoder64 default constructor leaves scaleIndex uninitialized
-
- Open
-
-
SERVER-131580 Turn on clang tidy check for uninitialized variable
-
- Backlog
-