Details
[Home]
Issue of the Standard # S0398
Brief
Inconsistency in constant definitions for mutex types in LSB 3.1 и в glibc-2.3.4.
Detailed Description
The OLVER test suite compiled on RHEL 4 Update 2 (glibc-2.3.4) with LSB Software Development Kit (SDK) detected the problem that occurs in the following code:
int code;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
code = pthread_mutex_trylock(&mutex);
code = pthread_mutex_trylock(&mutex);
code = pthread_mutex_unlock(&mutex);
code = pthread_mutex_destroy(&mutex);
The second call of the pthread_mutex_trylock() function should return EBUSY (as for PTHREAD_MUTEX_DEFAULT), but it returns 0 (as for PTHREAD_MUTEX_ RECURSIVE).
The cause of the problem is that constants for type of mutex are defined in LSB 3.1 in pthread.h as follows:
#define PTHREAD_MUTEX_DEFAULT 1
#define PTHREAD_MUTEX_NORMAL 1
#define PTHREAD_MUTEX_RECURSIVE 2
#define PTHREAD_MUTEX_ERRORCHECK 3
Whereas glibc 2.3.4 in pthread.h has the following definitions of the above constants:
enum
{
PTHREAD_MUTEX_TIMED_NP,
PTHREAD_MUTEX_RECURSIVE_NP,
PTHREAD_MUTEX_ERRORCHECK_NP,
PTHREAD_MUTEX_ADAPTIVE_NP
PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,
PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
};
As a result, constants for type of mutex have the following values:
PTHREAD_MUTEX_NORMAL = 0, PTHREAD_MUTEX_RECURSIVE = 1, PTHREAD_MUTEX_ERRORCHECK = 2, PTHREAD_MUTEX_DEFAULT = 0, that are not consistent with values defined in LSB 3.1.
Problem location(s) in the standard
Linux Standard Base Core Specification 3.1, Chapter 13. Base Libraries, 13.10. Data Definitions for libpthread, 13.10.1. pthread.h.<br> LSB Software Development Kit (SDK).
Possible consequences
Possible incorrect behavior of POSIX-compliant applications which are compiled using LSB Software Development Kit (SDK).
Accepted
LSB Bugzilla, 1432
Status
Fixed in LSB 3.1 Update 1
[Home]