Coverity fails to understand smart pointer ownership in LazilyInitialized

XMLWordPrintableJSON

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

      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
              Reporter:
              Carlos Alonso Pérez
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated: