Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Wiki Markup
POSIX defines PTHREAD_MUTEX_NORMAL locks to have the following undefined behavior \[[Open Group 4|https://www.securecoding.cert.org/confluence/display/seccode/AA.+C+References#AA.CReferences-OpenGroup04] \]
<blockquote>
<p>This type of mutex does not provide deadlock detection. A thread attempting to relock this mutex without first unlocking it shall deadlock.  An error is not returned to the caller. Attempting to unlock a mutex locked by a different thread results in undefined behavior.  Attempting to unlock an unlocked mutex results in undefined behavior.</p></blockquote>The

This type of mutex does not provide deadlock detection. A thread attempting to relock this mutex without first unlocking it shall deadlock. An error is not returned to the caller. Attempting to unlock a mutex locked by a different thread results in undefined behavior. Attempting to unlock an unlocked mutex results in undefined behavior.

Wiki Markup
The DEFAULT mutex type of pthreads is also generally mapped to PTHREAD_MUTEX_NORMAL which is seen across various implementations \[[SOL 10|http://docs.sun.com/app/docs/doc/816-5137/sync-28983?a=view] \]. Usage of
DEFAULT and
 NORMAL locks should be avoided and ERRORCHECK or RECURSIVE locks should be explicitly defined when using
any type of mutex lock
 mutex locks.

Noncompliant Code Example

...