-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Trivial - P5
-
Affects Version/s: None
-
Component/s: None
-
None
-
Storage Engines - Server Integration
-
Fully Compatible
-
ALL
-
-
None
-
None
-
None
-
None
-
None
-
None
-
None
In src/mongo/db/storage/devnull/devnull_kv_engine.h, the member int _cachePressureForTest; is declared without a default member initializer. The DevNullKVEngine::DevNullKVEngine() constructor (in devnull_kv_engine.cpp) initializes only _engineDbPath and does not assign _cachePressureForTest, so the member is left with an indeterminate value after construction.
The adjacent members are initialized deliberately, which indicates these fields are meant to hold defined values. Reading _cachePressureForTest before it is assigned would be undefined behavior. In the current tree the member is not read anywhere, so the defect is latent rather than active; the _forTest suffix suggests it is intended to be consumed by tests, at which point the uninitialized read would become reachable.
Found by static analysis (Svace, UNINIT.CTOR): "Constructor may not initialize class members of 'mongo::DevNullKVEngine'. Following members aren't initialized: _cachePressureForTest."
Suggested fix: give the member a default initializer in the header (e.g. int _cachePressureForTest = 0;) or initialize it in the constructor.