This is the mail archive of the libc-hacker@cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [Patch]: SIGSEGV: exceptions with thread specific data


> 
> > > What is the problem, exactly?  Why can't we share malloced memory between
> > > threads?
> > > 
> > 
> > I don't know for sure. Maybe Wolfram knows. It may be a bug in glibc.
> 
> glibc's malloc is most definitely thread-safe, as long as it
> is properly initialized.  Do the malloc() requests for exception
> handling happen very early, maybe even before glibc's constructors
> have run ?
> 
> I'll have more time to look into this later this week.  If someone
> can send me the latest test-case, I'd be grateful
> 

We shouldn't access p_specific when a thread has been terminated.
Otherwise, we will get a memory leak. 

Roland, do you want me to change __libc_internal_tsd_get and
__libc_internal_tsd_set to weak? Or you will do it yourself.

Thanks.

-- 
H.J. Lu (hjl@gnu.org)
---
Tue Mar 16 15:04:31 1999  H.J. Lu  <hjl@gnu.org>

	* specific.c (pthread_key_delete): Don't mark p_specific if
	the thread has been terminated.

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/16 23:02: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);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]