Bug 234313 - Dead lock between libefence and libpthread
Dead lock between libefence and libpthread
Product: Fedora
Classification: Fedora
Component: ElectricFence (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Petr Machata
Depends On:
  Show dependency treegraph
Reported: 2007-03-28 09:32 EDT by Olivier Baudron
Modified: 2015-05-04 21:33 EDT (History)
2 users (show)

See Also:
Fixed In Version: FC8
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2008-05-06 15:26:04 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Olivier Baudron 2007-03-28 09:32:33 EDT
The following testcase causes a deadlock.
It happens with 90% probability on my bi-proc machine.

/* ---------------- foo.c ---------------- */
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <errno.h>
#include <string.h>
#include <sys/wait.h>

void check_error (int err) {
    if (err) {
        printf ("Error : %s\n", strerror (errno));
        exit (1);

void *new_thread (void *param) {
    int filedes[2], err;
    char buffer[256];
    pid_t child, pid;

    err = pipe (filedes);
    check_error (err);
    child = fork ();
    check_error (child == -1);
    if (child == 0) {
        err = close (filedes[0]);
        check_error (err == -1);
        if (filedes[1] > 1) {
            err = dup2 (filedes[1], 1);
            check_error (err == -1);
            err = close (filedes[1]);
            check_error (err == -1);
        err = execlp ("echo", "echo", "Hello", (char *) NULL);
        check_error (err == -1);
    err = close (filedes[1]);
    check_error (err == -1);
    while (read (filedes[0], buffer, 256));
    pid = waitpid (child, NULL, 0);
    check_error (pid == -1);
    err = close (filedes[0]);
    check_error (err == -1);
    return NULL;

int main (int argc, char **argv) {
    int i, err;
    pthread_t thread[20];
    pthread_attr_t attr;

    err = pthread_attr_init (&attr);
    check_error (err);
    for (i=0; i<20; i++) {
        err = pthread_create (thread+i, &attr, new_thread, NULL);
        check_error (err);
    for (i=0; i<20; i++) {
        err = pthread_join (thread[i], NULL);
        check_error (err);
    return 0;
/* -------------- end foo.c -------------- */

$ gcc -Wall -g -o foo foo.c -lpthread -lefence
$ ./foo

Never finish...

This is the shortest testcase I could produce.
Each thread creates a pipe, forks, then the child redirects its output in the
pipe and execve a simple command.

The deadlocks often occur while execve.
Comment 1 Olivier Baudron 2007-03-29 03:57:09 EDT
My report is a duplicate of bug 54368 which did not provide a testcase but had a
solution: use mutex instead of semaphore in libefence. This is a good idea since
performance is not an issue when debugging.
Comment 2 Bug Zapper 2008-04-04 02:42:34 EDT
Fedora apologizes that these issues have not been resolved yet. We're
sorry it's taken so long for your bug to be properly triaged and acted
on. We appreciate the time you took to report this issue and want to
make sure no important bugs slip through the cracks.

If you're currently running a version of Fedora Core between 1 and 6,
please note that Fedora no longer maintains these releases. We strongly
encourage you to upgrade to a current Fedora release. In order to
refocus our efforts as a project we are flagging all of the open bugs
for releases which are no longer maintained and closing them.

If this bug is still open against Fedora Core 1 through 6, thirty days
from now, it will be closed 'WONTFIX'. If you can reporduce this bug in
the latest Fedora version, please change to the respective version. If
you are unable to do this, please add a comment to this bug requesting
the change.

Thanks for your help, and we apologize again that we haven't handled
these issues to this point.

The process we are following is outlined here:

We will be following the process here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping to ensure this
doesn't happen again.

And if you'd like to join the bug triage team to help make things
better, check out http://fedoraproject.org/wiki/BugZappers
Comment 3 Bug Zapper 2008-05-06 15:26:02 EDT
This bug is open for a Fedora version that is no longer maintained and
will not be fixed by Fedora. Therefore we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen thus bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.
Comment 4 Olivier Baudron 2008-05-07 02:05:53 EDT
The bug is fixed in FC8:

Note You need to log in before you can comment on or make changes to this bug.