public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/2746] New: mutex with ERRORCHECK attribute fails to unlock on child after fork
@ 2006-06-09 19:26 rdabrowa at poczta dot onet dot pl
  2006-06-10  7:03 ` [Bug nptl/2746] " drepper at redhat dot com
  0 siblings, 1 reply; 2+ messages in thread
From: rdabrowa at poczta dot onet dot pl @ 2006-06-09 19:26 UTC (permalink / raw)
  To: glibc-bugs

pthread_mutex_unlock function unexpectedly fails when called in child process 
on a mutex, which:
 * has PTHREAD_MUTEX_ERRORCHECK or PTHREAD_MUTEX_RECURSIVE attribute
 * has been locked in parent process

Possibility of unlocking of a mutex locked in parent process is typically used 
in handlers installed by pthread_atfork routine and is supposed to work.

Code example:

#include <pthread.h>
#include <stdio.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
    pthread_mutex_t mutex;
    pthread_mutexattr_t attr;
    pid_t pid;
    int err;

    pthread_mutexattr_init(&attr);
    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
    pthread_mutex_init(&mutex, &attr);
    pthread_mutex_lock(&mutex);
    pid = fork();
    err = pthread_mutex_unlock(&mutex);
    printf("pid=%d, err=%d\n", pid, err);
    return 0;
}

---------------------------------------------------
Output:
    pid=0, err=1
    pid=5817, err=0
err should be 0 both on child and on parent.

-- 
           Summary: mutex with ERRORCHECK attribute fails to unlock on child
                    after fork
           Product: glibc
           Version: 2.3.6
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nptl
        AssignedTo: drepper at redhat dot com
        ReportedBy: rdabrowa at poczta dot onet dot pl
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=2746

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug nptl/2746] mutex with ERRORCHECK attribute fails to unlock on child after fork
  2006-06-09 19:26 [Bug nptl/2746] New: mutex with ERRORCHECK attribute fails to unlock on child after fork rdabrowa at poczta dot onet dot pl
@ 2006-06-10  7:03 ` drepper at redhat dot com
  0 siblings, 0 replies; 2+ messages in thread
From: drepper at redhat dot com @ 2006-06-10  7:03 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2006-06-10 07:02 -------


*** This bug has been marked as a duplicate of 2745 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


http://sourceware.org/bugzilla/show_bug.cgi?id=2746

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-06-10  7:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-09 19:26 [Bug nptl/2746] New: mutex with ERRORCHECK attribute fails to unlock on child after fork rdabrowa at poczta dot onet dot pl
2006-06-10  7:03 ` [Bug nptl/2746] " drepper at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).