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

Bug#454183: libc6: deadlock in syslog() after fork



On Monday 03 December 2007, you wrote:
> Marc Donner a écrit :
> > Package: libc6
> > Version: 2.5-7
> > Severity: important
> >
> > the syslog() funktion seems sometimes to end in a deadlock, if a
> > multithreaded process, where are threads logging to syslog, at the
> > same time does a fork() and the child trys to log something to syslog.
> > the child process hangs in the syslog call. the gdb backtrace is:
>
> Could you please retry with an up to date version of libc6 (2.6.1 or
> even 2.7)?

sorry bug exists also in libc6 2.7. I have tested with a small program:


#include <stdio.h>
#include <syslog.h>
#include <pthread.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>



void *
test_thread (void *arg) {
   int i;
   int j;

   i = 0;
   while (1) {
      for (j=0; j<300; j++) {
         syslog(LOG_INFO, "thread: %d", i);
      }
      usleep(30000);
      i++;
   }

   return NULL;
}

int
main (int argc, char **argv) {
   pthread_t t;
   int i;
   pid_t c;

   i = 0;

   signal(SIGCHLD, SIG_IGN);
   pthread_create(&t, NULL, test_thread, NULL);

   while (1) {
      c = fork();
      if (c < 0) {
         exit(1);
      } else if (c == 0) {
         syslog(LOG_INFO, "child: %d", i);
         exit(0);
      }
      usleep(28000);
      i++;
   }

   return 0;
}


after a few seconds threre are hanging child processes. the child process 
hangs in syslog(), trying to lock a mutex.

regards
Marc




Reply to: