Bug 19515 - wrong assertion in pthread_mutex_unlock() with lock elision
Summary: wrong assertion in pthread_mutex_unlock() with lock elision
Status: RESOLVED DUPLICATE of bug 17514
Alias: None
Product: glibc
Classification: Unclassified
Component: nptl (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL: https://bugs.debian.org/cgi-bin/bugre...
Depends on:
Reported: 2016-01-23 20:26 UTC by Aurelien Jarno
Modified: 2016-01-25 06:40 UTC (History)
1 user (show)

See Also:
Last reconfirmed:
fweimer: security-


Note You need to log in before you can comment on or make changes to this bug.
Description Aurelien Jarno 2016-01-23 20:26:20 UTC
The following code from Andreas Messer fails with an assertion when run on a system with hardware support for lock elision, and with a libc with lock elision enabled.

#include <pthread.h>
#include <time.h>

int main(int argc, char* argv[])
  pthread_mutex_t mutex;
  pthread_mutexattr_t attr;
  struct timespec ts;

  pthread_mutexattr_init( &attr );
  pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_ERRORCHECK );
  pthread_mutex_init( &mutex, &attr );

  clock_gettime( CLOCK_REALTIME, &ts );
  ts.tv_sec += 3;
  pthread_mutex_timedlock( &mutex, &ts );
  return 0;

It returns the following assertion:

a.out: pthread_mutex_unlock.c:87: __pthread_mutex_unlock_usercnt: Assertion `type == PTHREAD_MUTEX_ERRORCHECK_NP' failed.

Patch will follow on the mailing list.
Comment 1 Andreas Schwab 2016-01-23 21:34:37 UTC

*** This bug has been marked as a duplicate of bug 17514 ***