Coverity analysis defect 100734: Value not atomically updated

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Storage
    • Storage Execution
    • Fully Compatible
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Non-atomic update of a concurrently shared value

      Defect 100734 (STATIC_C)
      Checker ATOMICITY (subcategory none)
      File: /src/mongo/db/storage/kv/kv_storage_engine.cpp
      Function mongo::KVStorageEngine::dropDatabase(mongo::OperationContext *, mongo::StringData)
      /src/mongo/db/storage/kv/kv_storage_engine.cpp, line: 217
      Locking "this->_dbsLock".

                  stdx::lock_guard<stdx::mutex> lk(_dbsLock);
      

      /src/mongo/db/storage/kv/kv_storage_engine.cpp, line: 221
      Assigning data that might be protected by the lock to "entry".

                  entry = it->second;
      

      /src/mongo/db/storage/kv/kv_storage_engine.cpp, line: 222
      Unlocking "lk._M_device". "entry" might now be unreliable because other threads can now change the data that it depends on.

              }
      

      /src/mongo/db/storage/kv/kv_storage_engine.cpp, line: 243
      Locking "this->_dbsLock" again.

                  stdx::lock_guard<stdx::mutex> lk(_dbsLock);
      

      /src/mongo/db/storage/kv/kv_storage_engine.cpp, line: 244
      Using an unreliable value of "entry" inside the second locked section. If the data that "entry" depends on was changed by another thread, this use might be incorrect.

                  opCtx->recoveryUnit()->registerChange(new RemoveDBChange(this, db, entry));
      

            Assignee:
            [DO NOT USE] Backlog - Storage Execution Team
            Reporter:
            Coverity Collector User
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: