public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* A patch for linuxthreads
@ 1999-04-14 22:31 H.J. Lu
  1999-04-14 23:51 ` Ulrich Drepper
  0 siblings, 1 reply; 20+ messages in thread
From: H.J. Lu @ 1999-04-14 22:31 UTC (permalink / raw)
  To: GNU C Library; +Cc: Ulrich Drepper

Ulrich,

This patch is almost a month old.

1. If th->p_terminated is 1, th->p_specific is already deleted. If
you delete them again, you may corrupt the memory.
2. __libc_internal_tsd_get and __libc_internal_tsd_set are referenced
in malloc/malloc.c and defined in linuxthreads/no-tsd.c. We want to
override them with -lpthread. To do that, we have to make them global
in libc.so.

Thanks.

-- 
H.J. Lu (hjl@gnu.org)
---
Tue Mar 16 19:30:50 1999  H.J. Lu  <hjl@gnu.org>

	* specific.c (pthread_key_delete): Check th->p_terminated to
	if the thread is running.

	* Versions (__libc_internal_tsd_get, __libc_internal_tsd_set):
	Added to GLIBC_2.0 for libc.so.

Index: specific.c
===================================================================
RCS file: /local/work/cvs/gnu/glibc/linuxthreads/specific.c,v
retrieving revision 1.1.1.5
diff -u -p -r1.1.1.5 specific.c
--- specific.c	1998/12/01 16:22:30	1.1.1.5
+++ specific.c	1999/03/26 01:08:41
@@ -80,7 +80,7 @@ int pthread_key_delete(pthread_key_t key
   idx2nd = key % PTHREAD_KEY_2NDLEVEL_SIZE;
   th = self;
   do {
-    if (th->p_specific[idx1st] != NULL)
+    if (!th->p_terminated && th->p_specific[idx1st] != NULL)
       th->p_specific[idx1st][idx2nd] = NULL;
     th = th->p_nextlive;
   } while (th != self);
Index: Versions
===================================================================
RCS file: /local/work/cvs/gnu/glibc/linuxthreads/Versions,v
retrieving revision 1.1.1.3
diff -u -p -r1.1.1.3 Versions
--- Versions	1999/02/16 23:21:28	1.1.1.3
+++ Versions	1999/03/26 01:08:41
@@ -13,6 +13,9 @@ libc {
     pthread_mutexattr_getkind_np; pthread_mutexattr_setkind_np;
     pthread_self; pthread_setcancelstate; pthread_setcanceltype;
     pthread_setschedparam;
+
+    # Internal libc interface to libpthread
+    __libc_internal_tsd_get; __libc_internal_tsd_set;
   }
   GLIBC_2.1 {
     pthread_attr_init;

^ permalink raw reply	[flat|nested] 20+ messages in thread
* A patch for linuxthreads
@ 2000-09-04 10:48 H . J . Lu
  2000-09-04 19:54 ` Ulrich Drepper
  0 siblings, 1 reply; 20+ messages in thread
From: H . J . Lu @ 2000-09-04 10:48 UTC (permalink / raw)
  To: GNU C Library

page_roundup is faster than roundup. Since `ps' is returned from
__getpagesize (), it should be ok.


-- 
H.J. Lu (hjl@gnu.org)
---
2000-09-04  H.J. Lu  <hjl@gnu.org>

	* attr.c (__pthread_attr_setguardsize): Use page_roundup
	instead of roundup to round up to the page size.

Index: attr.c
===================================================================
RCS file: /work/cvs/gnu/glibc/linuxthreads/attr.c,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 attr.c
--- attr.c	2000/08/16 00:55:46	1.1.1.2
+++ attr.c	2000/08/17 16:18:05
@@ -147,7 +147,7 @@ int __pthread_attr_setguardsize(pthread_
   size_t ps = __getpagesize ();
 
   /* First round up the guard size.  */
-  guardsize = roundup (guardsize, ps);
+  guardsize = page_roundup (guardsize, ps);
 
   /* The guard size must not be larger than the stack itself */
   if (guardsize >= attr->__stacksize) return EINVAL;

^ permalink raw reply	[flat|nested] 20+ messages in thread
* A patch for linuxthreads
@ 1999-12-16 16:12 H . J . Lu
       [not found] ` <199912170033.QAA01416@localhost.cygnus.com>
  0 siblings, 1 reply; 20+ messages in thread
From: H . J . Lu @ 1999-12-16 16:12 UTC (permalink / raw)
  To: GNU C Library

Hi,

While working on the ia64 port for linuxthreads, I found
this patch was necessary. Any comments?

Thanks.


-- 
H.J. Lu (hjl@gnu.org)
---
Thu Dec 16 15:59:58 1999  H.J. Lu  <hjl@gnu.org>

	* manager.c (pthread_allocate_stack): Correct the calculation
	of "new_thread_bottom".

Index: manager.c
===================================================================
RCS file: /work/cvs/gnu/glibc-2.1/linuxthreads/manager.c,v
retrieving revision 1.1.1.22
diff -u -p -r1.1.1.22 manager.c
--- manager.c	1999/11/27 18:44:03	1.1.1.22
+++ manager.c	1999/12/17 00:10:18
@@ -291,7 +291,7 @@ static int pthread_allocate_stack(const 
     {
       /* Allocate space for stack and thread descriptor at default address */
       new_thread = default_new_thread;
-      new_thread_bottom = (char *) new_thread - STACK_SIZE;
+      new_thread_bottom = (char *) (new_thread + 1) - STACK_SIZE;
       if (mmap((caddr_t)((char *)(new_thread + 1) - INITIAL_STACK_SIZE),
                INITIAL_STACK_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC,
                MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED | MAP_GROWSDOWN,

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: A patch for linuxthreads
@ 1999-03-17 13:44 Mike Stump
  1999-03-18  7:44 ` H.J. Lu
  0 siblings, 1 reply; 20+ messages in thread
From: Mike Stump @ 1999-03-17 13:44 UTC (permalink / raw)
  To: hjl, libc-hacker

> From: hjl@lucon.org (H.J. Lu)
> To: libc-hacker@cygnus.com (GNU C Library)
> Date: Tue, 16 Mar 1999 20:28:23 -0800 (PST)

> The problem is we should not access those key data stuctures after
> a thread is terminared since they have been freed.

> The patch for Versions fixes another bug. 

> Index: specific.c
> ===================================================================
> RCS file: /work/cvs/gnu/glibc/linuxthreads/specific.c,v
> retrieving revision 1.1.1.5
> diff -u -p -r1.1.1.5 specific.c
> --- specific.c	1998/12/01 16:22:30	1.1.1.5
> +++ specific.c	1999/03/17 03:30:10
> @@ -80,7 +80,7 @@ int pthread_key_delete(pthread_key_t key
>    idx2nd = key % PTHREAD_KEY_2NDLEVEL_SIZE;
>    th = self;
>    do {
> -    if (th->p_specific[idx1st] != NULL)
> +    if (!th->p_terminated && th->p_specific[idx1st] != NULL)
>        th->p_specific[idx1st][idx2nd] = NULL;
>      th = th->p_nextlive;
>    } while (th != self);

Forgive my possible ignorance, but if on an future SMP system, you can
have two threads running on different CPUs at the same time in a
shared memory system, and there is no `other' locking, the above seems
like it needs a lock around it.

^ permalink raw reply	[flat|nested] 20+ messages in thread
* A patch for linuxthreads
@ 1999-03-16 20:28 H.J. Lu
  1999-03-17  2:20 ` Mark Kettenis
  1999-03-17  4:52 ` Andrey Slepuhin
  0 siblings, 2 replies; 20+ messages in thread
From: H.J. Lu @ 1999-03-16 20:28 UTC (permalink / raw)
  To: GNU C Library; +Cc: egcs-bugs

Hi,

This Linuxthreads patch should fix

http://egcs.cygnus.com/ml/egcs-bugs/1999-03/msg00316.html

The problem is we should not access those key data stuctures after
a thread is terminared since they have been freed.

The patch for Versions fixes another bug. 


-- 
H.J. Lu (hjl@gnu.org)
--
Tue Mar 16 19:30:50 1999  H.J. Lu  <hjl@gnu.org>

	* specific.c (pthread_key_delete): Check th->p_terminated to
	if the thread is running.

	* Versions (__libc_internal_tsd_get, __libc_internal_tsd_set):
	Added to GLIBC_2.0 for libc.so.

Index: Versions
===================================================================
RCS file: /work/cvs/gnu/glibc/linuxthreads/Versions,v
retrieving revision 1.1.1.3
diff -u -p -r1.1.1.3 Versions
--- Versions	1999/02/16 23:21:28	1.1.1.3
+++ Versions	1999/03/17 04:21:23
@@ -13,6 +13,9 @@ libc {
     pthread_mutexattr_getkind_np; pthread_mutexattr_setkind_np;
     pthread_self; pthread_setcancelstate; pthread_setcanceltype;
     pthread_setschedparam;
+
+    # Internal libc interface to libpthread
+    __libc_internal_tsd_get; __libc_internal_tsd_set;
   }
   GLIBC_2.1 {
     pthread_attr_init;
Index: specific.c
===================================================================
RCS file: /work/cvs/gnu/glibc/linuxthreads/specific.c,v
retrieving revision 1.1.1.5
diff -u -p -r1.1.1.5 specific.c
--- specific.c	1998/12/01 16:22:30	1.1.1.5
+++ specific.c	1999/03/17 03:30:10
@@ -80,7 +80,7 @@ int pthread_key_delete(pthread_key_t key
   idx2nd = key % PTHREAD_KEY_2NDLEVEL_SIZE;
   th = self;
   do {
-    if (th->p_specific[idx1st] != NULL)
+    if (!th->p_terminated && th->p_specific[idx1st] != NULL)
       th->p_specific[idx1st][idx2nd] = NULL;
     th = th->p_nextlive;
   } while (th != self);

^ permalink raw reply	[flat|nested] 20+ messages in thread
* A patch for linuxthreads
@ 1998-12-02 10:35 H.J. Lu
  1998-12-02 11:44 ` Ulrich Drepper
  0 siblings, 1 reply; 20+ messages in thread
From: H.J. Lu @ 1998-12-02 10:35 UTC (permalink / raw)
  To: GNU C Library

Please ignore my last patch for linuxthreads. This one should be used.

Thanks.


-- 
H.J. Lu (hjl@gnu.org)
---
Wed Dec  2 08:40:43 1998  H.J. Lu  <hjl@gnu.org>

	* pthread.c (__pthread_sig_restart): Initiliaze to -1 if
	SIGRTMIN is defined.
	(__pthread_sig_cancel): Likewise.

Index: pthread.c
===================================================================
RCS file: /home/work/cvs/gnu/glibc/linuxthreads/pthread.c,v
retrieving revision 1.1.1.8
diff -u -p -r1.1.1.8 pthread.c
--- pthread.c	1998/10/31 16:47:04	1.1.1.8
+++ pthread.c	1998/12/02 18:33:36
@@ -147,8 +147,13 @@ const int __pthread_offsetof_pid = offse
                                             p_pid);
 
 /* Signal numbers used for the communication.  */
+#ifdef SIGRTMIN
+int __pthread_sig_restart = -1;
+int __pthread_sig_cancel = -1;
+#else
 int __pthread_sig_restart = DEFAULT_SIG_RESTART;
 int __pthread_sig_cancel = DEFAULT_SIG_CANCEL;
+#endif
 
 /* These variables are used by the setup code.  */
 extern int _errno;

^ permalink raw reply	[flat|nested] 20+ messages in thread
* A patch for linuxthreads
@ 1998-10-24 18:33 H.J. Lu
  1998-10-25  0:59 ` Ulrich Drepper
  0 siblings, 1 reply; 20+ messages in thread
From: H.J. Lu @ 1998-10-24 18:33 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: GNU C Library

We should not include them indiscriminately.


-- 
H.J. Lu (hjl@gnu.org)
---
Sat Oct 24 18:15:53 1998  H.J. Lu  <hjl@gnu.org>

	* linuxthreads/sysdeps/pthread/bits/pthreadtypes.h: Protect
	with __USE_REENTRANT, __USE_MISC, __USE_GNU and _PTHREAD_H.
	* linuxthreads/sysdeps/unix/sysv/linux/bits/sigthread.h:
	Likewise.

Index: linuxthreads/sysdeps/pthread/bits/pthreadtypes.h
===================================================================
RCS file: /home/work/cvs/gnu/glibc/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 pthreadtypes.h
--- pthreadtypes.h	1998/07/01 02:47:57	1.1.1.1
+++ pthreadtypes.h	1998/10/22 14:22:52
@@ -19,6 +19,9 @@
 #ifndef _BITS_PTHREADTYPES_H
 #define _BITS_PTHREADTYPES_H	1
 
+#if defined __USE_REENTRANT || defined __USE_MISC || \
+    defined __USE_GNU || defined _PTHREAD_H
+
 #define __need_schedparam
 #include <bits/sched.h>
 
@@ -115,5 +118,7 @@
 
 /* Thread identifiers */
 typedef unsigned long int pthread_t;
+
+#endif
 
 #endif	/* bits/pthreadtypes.h */
Index: linuxthreads/sysdeps/unix/sysv/linux/bits/sigthread.h
===================================================================
RCS file: /home/work/cvs/gnu/glibc/linuxthreads/sysdeps/unix/sysv/linux/bits/sigthread.h,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 sigthread.h
--- sigthread.h	1998/09/14 16:08:53	1.1.1.3
+++ sigthread.h	1998/10/22 14:23:06
@@ -24,6 +24,9 @@
 # error "Never include this file directly.  Use <pthread.h> instead"
 #endif
 
+#if defined __USE_REENTRANT || defined __USE_MISC || \
+    defined __USE_GNU || defined _PTHREAD_H
+
 /* Functions for handling signals. */
 
 /* Modify the signal mask for the calling thread.  The arguments have
@@ -33,5 +36,7 @@
 
 /* Send signal SIGNO to the given thread. */
 extern int pthread_kill __P ((pthread_t __thread, int __signo));
+
+#endif
 
 #endif	/* bits/sigthread.h */

^ permalink raw reply	[flat|nested] 20+ messages in thread
* A patch for linuxthreads
@ 1998-08-08 23:26 H.J. Lu
  1998-08-09  8:59 ` Ulrich Drepper
  0 siblings, 1 reply; 20+ messages in thread
From: H.J. Lu @ 1998-08-08 23:26 UTC (permalink / raw)
  To: GNU C Library

Hi,

Here is a patch for linuxthreads.


-- 
H.J. Lu (hjl@gnu.org)
---
Sat Aug  8 11:18:52 1998  H.J. Lu  (hjl@gnu.org)

	* signals.c (sigaction): Handle NULL argument.

Index: signals.c
===================================================================
RCS file: /home/work/cvs/gnu/glibc/linuxthreads/signals.c,v
retrieving revision 1.1.1.3
diff -u -p -r1.1.1.3 signals.c
--- signals.c	1998/07/30 18:36:36	1.1.1.3
+++ signals.c	1998/08/08 18:10:18
@@ -93,16 +93,24 @@ int sigaction(int sig, const struct siga
               struct sigaction * oact)
 {
   struct sigaction newact;
+  struct sigaction *newactp;
 
   if (sig == __pthread_sig_restart || sig == __pthread_sig_cancel)
     return EINVAL;
-  newact = *act;
-  if (act->sa_handler != SIG_IGN && act->sa_handler != SIG_DFL)
-    newact.sa_handler = pthread_sighandler;
-  if (__sigaction(sig, &newact, oact) == -1)
+  if (act)
+    {
+      newact = *act;
+      if (act->sa_handler != SIG_IGN && act->sa_handler != SIG_DFL)
+	newact.sa_handler = pthread_sighandler;
+      newactp = &newact;
+    }
+  else
+    newactp = NULL;
+  if (__sigaction(sig, newactp, oact) == -1)
     return -1;
   if (oact != NULL) oact->sa_handler = sighandler[sig];
-  sighandler[sig] = act->sa_handler;
+  if (act)
+    sighandler[sig] = act->sa_handler;
   return 0;
 }
 

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

end of thread, other threads:[~2000-09-04 19:54 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-04-14 22:31 A patch for linuxthreads H.J. Lu
1999-04-14 23:51 ` Ulrich Drepper
  -- strict thread matches above, loose matches on Subject: below --
2000-09-04 10:48 H . J . Lu
2000-09-04 19:54 ` Ulrich Drepper
1999-12-16 16:12 H . J . Lu
     [not found] ` <199912170033.QAA01416@localhost.cygnus.com>
1999-12-16 16:43   ` H . J . Lu
1999-03-17 13:44 Mike Stump
1999-03-18  7:44 ` H.J. Lu
1999-03-16 20:28 H.J. Lu
1999-03-17  2:20 ` Mark Kettenis
1999-03-17  7:21   ` H.J. Lu
1999-03-17  4:52 ` Andrey Slepuhin
1998-12-02 10:35 H.J. Lu
1998-12-02 11:44 ` Ulrich Drepper
1998-10-24 18:33 H.J. Lu
1998-10-25  0:59 ` Ulrich Drepper
1998-10-25  8:22   ` H.J. Lu
1998-10-25  8:22     ` Ulrich Drepper
1998-08-08 23:26 H.J. Lu
1998-08-09  8:59 ` Ulrich Drepper

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).