pthread_rwlock_wrlock hangs with nptl

Andreas Jaeger aj@suse.de
Wed Feb 18 10:13:00 GMT 2004


The following program (extracted from mysql) hangs with nptl but not
with linuxthreads on x86-64.

#define _GNU_SOURCE
#include <pthread.h>
#include <stdio.h>
#include <string.h>


int main(void)
{
  pthread_rwlock_t LL;
  int ret;
  
  memset (&LL, 1, sizeof(LL));
  ret = pthread_rwlock_init(&LL, NULL);

  printf ("ret is: %d\n", ret);
  
  ret = pthread_rwlock_rdlock(&LL);
  printf ("ret is: %d\n", ret);
  ret = pthread_rwlock_unlock(&LL);
  printf ("ret is: %d\n", ret);
  ret = pthread_rwlock_wrlock(&LL); /* hangs with nptl */
  printf ("ret is: %d\n", ret);

  return 0;
}

After the rwlock_unlock, we have:
(gdb) p LL
$7 = {__data = {__lock = 0, __nr_readers = 1, __readers_wakeup = 0,
    __writer_wakeup = 0, __nr_readers_queued = 0, __nr_writers_queued = 0,
    __writer = 0, __pad1 = 0, __pad2 = 18446744073709551615,
    __pad3 = 18446744073709551615, __flags = 0},
  __size = "\000\000\000\000\001", '\0' <repeats 27 times>, 'ÿ' <repeats 16 times>, "\000\000\000\000ÿÿÿÿ", __align = 4294967296}

and then the pthread_rwlock_wrlock hangs...

Any ideas what's wrong here?

Andreas
-- 
 Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj
  SuSE Linux AG, Maxfeldstr. 5, 90409 Nürnberg, Germany
   GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20040218/dc7ba0f3/attachment.sig>


More information about the Libc-alpha mailing list