https://bugzilla.novell.com/show_bug.cgi?id=865968
https://bugzilla.novell.com/show_bug.cgi?id=865968#c19
Jim Mattson changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEEDINFO |NEW
InfoProvider|jmattson@vmware.com |
--- Comment #19 from Jim Mattson 2014-03-03 18:36:55 UTC ---
I misinterpreted what I was seeing, and I jumped to the wrong conclusion.
The actual problem is that a successful trylock followed by an unlock reduces
__nusers below 0. Here's a sample:
#include
#include
#include
#include
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
void lockN(int n)
{
int i;
for (i = 0; i < n; i++) {
if (pthread_mutex_trylock (&mutex) == 0) {
pthread_mutex_unlock (&mutex);
}
}
}
int main()
{
int rc;
lockN(5);
if ((rc = pthread_mutex_destroy(&mutex)) != 0) {
error(1, errno, "pthread_mutex_destroy failed with %d", rc);
}
}
Run on pre-Haswell systems, this program succeeds.
Run on Haswell systems, it fails as follows:
/foo: pthread_mutex_destroy failed with 16
On a Haswell system, we can see that __nusers has gone negative:
Breakpoint 1, main () at foo.c:22
22 if ((rc = pthread_mutex_destroy(&mutex)) != 0) {
(gdb) p mutex
$1 = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 4294967291,
__kind = 0, __spins = 196608, __list = {__prev = 0x0,
__next = 0x0}}, __size = '\000' ,
"\373\377\377\377\000\000\000\000\000\000\003", '\000' ,
__align = 0}
(gdb) p (int)4294967291
$2 = -5
Pre-Haswell, __nusers is 0, as expected:
Breakpoint 1, main () at foo.c:22
22 if ((rc = pthread_mutex_destroy(&mutex)) != 0) {
(gdb) p mutex
$1 = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0,
__spins = 0, __list = {
__prev = 0x0, __next = 0x0}}, __size = '\000' , __align
= 0}
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.