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

Coverity analysis defect 162325: Different smart pointers managing same raw pointer

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Networking & Observability
    • ALL
    • Networking & Obs 2025-01-20

      Different smart pointers managing same raw pointer

      This may cause a crash, as different smart pointers may try to delete the raw pointer twice. Same raw pointer is used to initialize or reset two or more different smart pointers.
      /data/bazel_cache/1de52aaeb35278243ca29a4785ce7969/execroot/_main_/src/mongo/executor/connection_pool.cpp:1017: MULTIPLE_INIT_SMART_PTRS 162325 Function "shared_ptr" assigns "conn" with "std::move(iter->second)".
      /data/bazel_cache/1de52aaeb35278243ca29a4785ce7969/execroot/_main_/src/mongo/executor/connection_pool.cpp:1032: MULTIPLE_INIT_SMART_PTRS 162325 Function "get" returns a pointer managed by "conn".
      /data/bazel_cache/1de52aaeb35278243ca29a4785ce7969/execroot/_main_/src/mongo/executor/connection_pool.cpp:1032: MULTIPLE_INIT_SMART_PTRS 162325 Assigning: "<temporary>" = "conn.get()".
      /data/bazel_cache/1de52aaeb35278243ca29a4785ce7969/execroot/_main_/src/mongo/executor/connection_pool.cpp:1033: MULTIPLE_INIT_SMART_PTRS 162325 Function "operator =" assigns "mappedConn" with "std::move(conn)".
      /data/bazel_cache/1de52aaeb35278243ca29a4785ce7969/execroot/_main_/src/mongo/executor/connection_pool.cpp:1037: MULTIPLE_INIT_SMART_PTRS 162325 Function "get" returns a pointer managed by "mappedConn".

            Assignee:
            joseph.prince@mongodb.com Joseph Prince
            Reporter:
            xgen-internal-coverity Coverity Collector User
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: