Wrong Lock order reversal issue in C/C++

  • Using SonarQube 8.5 build 37579 Developer Edition and latest sonar-scanner under linux environment.

Hello
Analyzing C++ project we get severan issues with the rule “This was not the most recently acquired lock. Possible lock order reversal” using pthread_mutex_lock/unlock. After manual revision, we can’t find why. This happens on any file using this family of mutexes.

Example of function with the issue:


   pthread_mutex_lock(this->mutex);

   this->disconnect(); //No mutex management on this function

   pthread_mutex_unlock(this->mutex); ->This was not the most recently acquired lock. Possible lock order reversal.
   pthread_mutex_destroy(this->mutex);
   delete this->mutex;
   return;
}

Hello @jggundin,

Welcome to the community!

We are aware of this false-positive CPP-2568. We will try to fix it soon but no ETA. Feel free to watch the ticket for any updates.

Thank you,

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.