This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Don't do lock elision on an error checking mutex (bug 17514)
- From: Florian Weimer <fweimer at redhat dot com>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: libc-alpha at sourceware dot org
- Date: Thu, 14 Jan 2016 12:04:19 +0100
- Subject: Re: [PATCH] Don't do lock elision on an error checking mutex (bug 17514)
- Authentication-results: sourceware.org; auth=none
- References: <mvma8o8qz1c dot fsf at hawking dot suse dot de>
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