Bug 19515

Summary: wrong assertion in pthread_mutex_unlock() with lock elision
Product: glibc Reporter: Aurelien Jarno <aurelien>
Component: nptlAssignee: Not yet assigned to anyone <unassigned>
Severity: normal CC: drepper.fsp
Priority: P2 Flags: fweimer: security-
Version: unspecified   
Target Milestone: ---   
URL: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=810322
Host: Target:
Build: Last reconfirmed:

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 ***