Coverity analysis defect 176115: Check of thread-shared field evades lock acquisition

XMLWordPrintableJSON

    • Query Integration
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Check of thread-shared field evades lock acquisition

      The data guarded by this critical section may be read while in an inconsistent state or modified by multiple racing threads. Checking the value of a thread-shared field outside of a locked region to determine if a locked operation involving that thread shared field has completed.
      /src/mongo/scripting/mozjs/proxyscope.cpp:409: LOCK_EVASION 176115 The thread 1 uses the value read from field "_state" in the condition "proxy->_state == mongo::mozjs::MozJSProxyScope::State::Shutdown". It sees that the condition is false. After the thread 1 leaves the critical section, control is switched to the thread 2.
      /src/mongo/scripting/mozjs/proxyscope.cpp:404: LOCK_EVASION 176115 The thread 2 acquires lock "mongo::mozjs::MozJSProxyScope._mutex".
      /src/mongo/scripting/mozjs/proxyscope.cpp:409: LOCK_EVASION 176115 The thread 2 uses the value read from field "_state" in the condition "proxy->_state == mongo::mozjs::MozJSProxyScope::State::Shutdown". It sees that the condition is false.
      /src/mongo/scripting/mozjs/proxyscope.cpp:420: LOCK_EVASION 176115 The thread 2 sets "_state" to a new value. Note that this write can be reordered at runtime to occur before instructions that do not access this field, even into (but not to the other side of) preceding locked regions. Control is switched back to the thread 1.
      /src/mongo/scripting/mozjs/proxyscope.cpp:420: LOCK_EVASION 176115 The thread 1 sets "_state" to a new value. Now the two threads have an inconsistent view of "_state" and updates to fields correlated with "_state" may be lost.

            Assignee:
            Erin Liang
            Reporter:
            Coverity Collector User
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: