Bug 11771

Summary: pthread_mutex_trylock is not weakly defined in glibc-2.1.3-15
Product: [Retired] Red Hat Linux Reporter: Daphne Shaw <dshaw>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0CC: fweimer
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-04-22 00:14:14 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Daphne Shaw 2000-05-31 04:05:19 UTC
glibc defines all of the pthread_* functions weakly within glibc itself so
a program that uses them but does not link with libpthreads will still
function.  The functions are weakly defined to return a "no error" code.

Unfortunately, for some reason pthread_mutex_trylock was left out.

For example, this code works fine whether you link to libpthread or not:
  #include <pthread.h>
  
  int main(int argc,char *argv[])
  {
    pthread_mutex_t mymutex=PTHREAD_MUTEX_INITIALIZER;
  
    pthread_mutex_lock(&mymutex);
  }

On the other hand, this does not work (but should):

  #include <pthread.h>

  int main(int argc,char *argv[])
  {
    pthread_mutex_t mymutex=PTHREAD_MUTEX_INITIALIZER;

    pthread_mutex_trylock(&mymutex);
  }

Comment 1 Alan Cox 2002-12-14 23:43:45 UTC
Still the same in 8.0 if this is actually a bug its still there

Alan the bugzilla womble


Comment 2 Ulrich Drepper 2003-04-22 00:14:14 UTC
If pthread_mutex_trylock isn't used, why should it have been defined?  The
definitions are not meant for programmers to rely on.

RHL9 changed all that code, calling thread functions from libc works completely
different now, even in the LinuxThreads code.  I close the bug.