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

Coverity fails to understand smart pointer ownership in LazilyInitialized

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • ALL

      When analysing LazilyInitialized<T>, Coverity keeps reporting a resource leak issue but that is not the case.

      The reason is that Coverity does not track auto_ptr before it sees the release() method call, and therefore doesn't care that when `compareAndSwap` succeeds, the pointer data has been owned by _ptr and therefore it is safe to release it afterwards.

      This has caused a number of reports being then flagged by engineers as false positives with the corresponding waste of time. See SERVER-90817SERVER-90816SERVER-90815SERVER-90814, SERVER-90450

            Assignee:
            asya.kamsky@mongodb.com Asya Kamsky
            Reporter:
            c.alonso@mongodb.com Carlos Alonso Pérez
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: