about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-03-17 00:07:36 +0000
committerUlrich Drepper <drepper@redhat.com>1998-03-17 00:07:36 +0000
commit48fc3dd2248fbfd6cd9e786fec89dffc604ead35 (patch)
tree1029adb52e33766b81821d19c58079cc5dc64cc7
parent22bc79788225fb13ff8e66d38e0dd92d44b1e588 (diff)
downloadglibc-48fc3dd2248fbfd6cd9e786fec89dffc604ead35.tar.gz
glibc-48fc3dd2248fbfd6cd9e786fec89dffc604ead35.tar.xz
glibc-48fc3dd2248fbfd6cd9e786fec89dffc604ead35.zip
Update.
1998-03-17 00:06  Ulrich Drepper  <drepper@cygnus.com>

	* manager.c: Fix last patch which caused core dumps.

	* pthread.c: Correctly handle missing SIGRTMIN.
-rw-r--r--linuxthreads/ChangeLog6
-rw-r--r--linuxthreads/manager.c21
-rw-r--r--linuxthreads/pthread.c2
3 files changed, 20 insertions, 9 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index 61d11a9eb4..63a3b7c758 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -1,3 +1,9 @@
+1998-03-17 00:06  Ulrich Drepper  <drepper@cygnus.com>
+
+	* manager.c: Fix last patch which caused core dumps.
+
+	* pthread.c: Correctly handle missing SIGRTMIN.
+
 1998-03-15  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
 
 	* libpthread.map: Add __libc_internal_tsd_get and
diff --git a/linuxthreads/manager.c b/linuxthreads/manager.c
index a650bbe4dd..7fe4d468f6 100644
--- a/linuxthreads/manager.c
+++ b/linuxthreads/manager.c
@@ -100,6 +100,7 @@ int __pthread_manager(void *arg)
     timeout.tv_sec = 2;
     timeout.tv_usec = 0;
     n = __select(FD_SETSIZE, &readfds, NULL, NULL, &timeout);
+
     /* Check for termination of the main thread */
     if (getppid() == 1) {
       pthread_kill_all_threads(SIGKILL, 0);
@@ -179,7 +180,6 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
   int pid;
   pthread_descr new_thread;
   pthread_t new_thread_id;
-  int i;
   void *guardaddr = NULL;
 
   /* Find a free stack segment for the current stack */
@@ -201,11 +201,12 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
 	    {
 	      /* We manage to get a stack.  Now see whether we need a guard
 		 and allocate it if necessary.  */
-	      if (attr->guardsize != 0)
+	      if (attr == NULL || attr->guardsize != 0)
 		{
 		  guardaddr = mmap ((caddr_t)((char *)(new_thread+1)
-					      - 2*1024*1024),
-				    attr->guardsize, 0, MAP_FIXED, -1, 0);
+					      - STACK_SIZE),
+				    attr ? attr->guardsize : __getpagesize (),
+				    0, MAP_FIXED, -1, 0);
 		  if (guardaddr == MAP_FAILED)
 		    /* We don't make this an error.  */
 		    guardaddr = NULL;
@@ -245,11 +246,13 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
   new_thread->p_h_errnop = &new_thread->p_h_errno;
   new_thread->p_h_errno = 0;
   new_thread->p_guardaddr = guardaddr;
-  new_thread->p_guardsize = (attr == NULL || !attr->stackaddr_set
-			     ? attr->guardsize : 0);
+  new_thread->p_guardsize = (guardaddr == NULL
+			     ? 0
+			     : (attr == NULL
+				? __getpagesize () : attr->guardsize));
   new_thread->p_userstack = attr != NULL && attr->stackaddr_set;
-  for (i = 0; i < PTHREAD_KEY_1STLEVEL_SIZE; i++)
-    new_thread->p_specific[i] = NULL;
+  memset (new_thread->p_specific, '\0',
+	  PTHREAD_KEY_1STLEVEL_SIZE * sizeof (new_thread->p_specific[0]));
   /* Initialize the thread handle */
   __pthread_handles[sseg].h_spinlock = 0; /* should already be 0 */
   __pthread_handles[sseg].h_descr = new_thread;
@@ -285,7 +288,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
       {
 	munmap((caddr_t)((char *)(new_thread+1) - INITIAL_STACK_SIZE),
 	       INITIAL_STACK_SIZE);
-	if (attr->guardsize != 0)
+	if (new_thread->p_guardsize != 0)
 	  munmap(new_thread->p_guardaddr, new_thread->p_guardsize);
       }
     __pthread_handles[sseg].h_descr = NULL;
diff --git a/linuxthreads/pthread.c b/linuxthreads/pthread.c
index 729222e589..9699b4ddcc 100644
--- a/linuxthreads/pthread.c
+++ b/linuxthreads/pthread.c
@@ -166,6 +166,7 @@ static void pthread_initialize(void)
   /* The errno/h_errno variable of the main thread are the global ones.  */
   __pthread_initial_thread.p_errnop = &_errno;
   __pthread_initial_thread.p_h_errnop = &_h_errno;
+#ifdef SIGRTMIN
   /* Allocate the signals used.  */
   __pthread_sig_restart = __libc_allocate_rtsig (1);
   __pthread_sig_cancel = __libc_allocate_rtsig (1);
@@ -176,6 +177,7 @@ static void pthread_initialize(void)
       __pthread_sig_restart = SIGUSR1;
       __pthread_sig_cancel = SIGUSR2;
     }
+#endif
   /* Setup signal handlers for the initial thread.
      Since signal handlers are shared between threads, these settings
      will be inherited by all other threads. */