[PATCH] Don't do lock elision on an error checking mutex (bug 17514)

Florian Weimer fweimer@redhat.com
Thu Jan 14 11:04:00 GMT 2016


On 01/14/2016 10:40 AM, Andreas Schwab wrote:
> +  pthread_mutexattr_init (&mutexattr);
> +  pthread_mutexattr_settype (&mutexattr, PTHREAD_MUTEX_ERRORCHECK_NP);
> +
> +  pthread_mutex_init (&mutex, &mutexattr);
> +  pthread_mutexattr_destroy (&mutexattr);
> +
> +  pthread_mutex_timedlock (&mutex, &tms);
> +  /* The preceding call to pthread_mutex_timedlock erroneously enabled
> +     lock elision on the mutex, which triggered an assertion failure
> +     during unlock.  */

This comment is confusing because it temporal relationship is unclear
(past execution vs. past versions of glibc).

> +  pthread_mutex_unlock (&mutex);

Please add error checking for all the return values.  I believe the
error-checking mutex will give you a consistent result here.

Florian



More information about the Libc-alpha mailing list