Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Oct 1998 18:03:22 -0700 (PDT)
From:      Jason Evans <jasone@canonware.com>
To:        HighWind Software Information <info@highwind.com>
Cc:        current@FreeBSD.ORG
Subject:   Re: Another Serious libc_r problem
Message-ID:  <Pine.LNX.3.96.981019180052.8913A-100000@orkan.canonware.com>
In-Reply-To: <199810191835.OAA20137@highwind.com>

next in thread | previous in thread | raw e-mail | index | archive | help

Hmm, your test case is very similar to some code that was causing deadlock
for me.  However, I boiled it down to the following code as being the
actual bug.  We may be seeing the same thing (but maybe not; I haven't had
time to dig into this all the way).

Jason

Jason Evans
Email: [jasone@canonware.com]
Web: [http://www.canonware.com/~jasone]
Home phone: [(650) 856-8204]
Work phone: [(415) 808-8742]
Quote: ["Invention is 1% inspiration and 99% perspiration" - Thomas Edison]

========================

/* -*-mode:c-*- */

#ifndef _REENTRANT
#  define _REENTRANT
#endif

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

int
main()
{
  pthread_mutex_t mutex;
  int error;

  error = pthread_mutex_init(&mutex, NULL);
  if (error)
  {
    fprintf(stderr, "Error in pthread_mutex_init(): %s\n", strerror(error));
    exit(1);
  }

  fprintf(stderr, "About to lock mutex first time.\n");
  error = pthread_mutex_lock(&mutex);
  if (error)
  {
    fprintf(stderr, "Error in pthread_mutex_lock(): %s\n", strerror(error));
    exit(1);
  }

  fprintf(stderr, "About to lock mutex second time; expect deadlock.\n");
  error = pthread_mutex_lock(&mutex);
  if (error)
  {
    fprintf(stderr, "Error in pthread_mutex_lock(): %s\n", strerror(error));
    exit(1);
  }

  fprintf(stderr, "Wow, no deadlock.\n");

  error = pthread_mutex_destroy(&mutex);
  if (error)
  {
    fprintf(stderr, "Error in pthread_mutex_destroy(): %s\n", strerror(error));
    exit(1);
  }
  
  return 0;
}



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.3.96.981019180052.8913A-100000>