[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Is it a bug of PTHREAD_MUTEX_ERRORCHECK_NP ?



In tst-mutex2, when  link statically the library and no thread created,
there is no 
__pthread_initialize_minimal(). so pd == NULL. 
in pthread_mutex_lock.c,

    case PTHREAD_MUTEX_ERRORCHECK_NP:
      /* Check whether we already hold the mutex.  */
      if (mutex->__data.__owner == pd )
        return EDEADLK;

it will return EDEADLK for the first pthread_mutex_lock in tst-mutex2. Is it
wrong ? 
or do I miss sth? 

Here is the possible fix. 

diff -u pthread_mutex_lock.c.orig pthread_mutex_lock.c
--- pthread_mutex_lock.c.orig   Fri Mar  7 14:17:23 2003
+++ pthread_mutex_lock.c        Fri Mar  7 14:18:03 2003
@@ -56,8 +56,10 @@
       /* Error checking mutex.  */
     case PTHREAD_MUTEX_ERRORCHECK_NP:
       /* Check whether we already hold the mutex.  */
-      if (mutex->__data.__owner == pd)
-       return EDEADLK;
+      if (mutex->__data.__owner == pd && NULL != pd )
+        return EDEADLK;
+      if (NULL == pd && mutex->__data.__lock > 0 )
+        return EDEADLK;

       /* FALLTHROUGH */


> I enter the enviroment, and everything seems to work pretty much as 
> expected, but almost _every_ command does this:
> 
> hal3 root # ls /
> bin  boot  dev	etc  home  lib	mnt  proc	root  
> sbin  share  tmp	usr  var
> Segmentation fault
> 
> Ie, it does it's stuff then segfaults on exit.
> 
> I build glibc with headers from Linux 2.5.63+ like this:
> 
> cd $WDIR
> $SDIR/configure --exec-prefix=/ --prefix=/usr 
> --libexecdir=/bin/libexec 
> --infodir=/usr/share/info --disable-profile --enable-add-ons=nptl 
> --enable-kernel=2.5 --with-headers=$PDIR/kernel/usr/include --with-tls
> make -j4
> make install_root=$DDIR install
> make install_root=$DDIR localedata/install-locales
> 
> I'm also running a PAE enabled kernel on a dual P4 Xeon 
> machine, though 
> I can't imagine that matters?
> 
> If I rebuild the chroot environment with linuxthreads, 
> everything works 
> perfectly. (Literally just change nptl to linuxthreads in my build 
> script - no room for silly mistakes here)
> 
> I am at a bit of a loss here. Any suggestions apprieciated!
> 
> Andrew Walrond
> 
> 
> 
> -- 
> Phil-list mailing list
> Phil-list redhat com
> https://listman.redhat.com/mailman/listinfo/phil-list
> 





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]