PoolForHost default constructor leaves _socketTimeoutSecs uninitialized

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Networking & Observability
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In src/mongo/client/connpool.h, class PoolForHost has a default constructor PoolForHost::PoolForHost() which does not initialize the _socketTimeoutSecs member (a raw double), which has no default member initializer, so a default-constructed instance holds an indeterminate _socketTimeoutSecs. This member is used in PoolForHost::clear() when logging dropped connections via _makeDuration(_socketTimeoutSecs), and reading the uninitialized value constitutes undefined behavior, potentially causing unexpected behavior or crashes if _socketTimeoutSecs is not set before clear() is called.
      Found by static analysis (Svace, UNINIT.CTOR): "Constructor declared at connpool.cpp:104 may not initialize class members of 'mongo::PoolForHost'. Following members aren't initialized: _socketTimeoutSecs."
      The fix is to add a default member initializer (double _socketTimeoutSecs = 0.0 or initialize it explicitly in the constructor initializer list.

            Assignee:
            Unassigned
            Reporter:
            Петя Вдовин (EXT)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: