[Gc] RE: Thread creation deadlock with libgc

Boehm, Hans hans_boehm@hp.com
Wed, 2 Jul 2003 11:07:27 -0700


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C340C4.CC2DB0E0
Content-Type: text/plain;
	charset="iso-8859-1"

Thanks.

I applied the patch.  I also speculatively applied (since I can't test) the attached analogous patch to aix_irix_threads.c, which appeared to have the same problem.

Hans

> -----Original Message-----
> From: Dick Porter [mailto:dick@ximian.com]
> Sent: Tuesday, July 01, 2003 11:37 AM
> To: Boehm, Hans
> Cc: 'gc@linux.hpl.hp.com'; ximian-mono-list@ximian.com
> Subject: [Gc] RE: Thread creation deadlock with libgc
> 
> 
> On Thu, 2003-06-19 at 00:08, Boehm, Hans wrote:
> > I believe the following patch (consisting of a one line 
> deletion) solves the problem.
> > But this is subtle enough that additional testing would be 
> very useful.  I will include
> > this in 6.2 unless I hear of problems.
> 
> Thanks, that fixed the problem I was seeing at the time.  
> However, I've
> started seeing the deadlock again with libgc 6.2 while stress-testing
> mono, and I think I've tracked the problem down:
> 
> In pthread_support.c the pthread_create wrapper isn't checking the
> return value, and is waiting for the new thread's startup 
> semaphore even
> if the real pthread_create failed.  Proposed patch attached.
> 
> - Dick
> 
> 
> 


------_=_NextPart_000_01C340C4.CC2DB0E0
Content-Type: application/octet-stream;
	name="aix_irix_threads.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="aix_irix_threads.diff"

--- aix_irix_threads.c.orig	2003-07-02 11:06:59.000000000 -0700=0A=
+++ aix_irix_threads.c	2003-07-02 11:07:03.000000000 -0700=0A=
@@ -769,11 +769,13 @@=0A=
     /* with it.  Thus it doesn't matter whether it is otherwise		*/=0A=
     /* visible to the collector.					*/=0A=
 =0A=
-    si->registereddone =3D 0;=0A=
-    pthread_mutex_lock(&(si->registeredlock));=0A=
-    while (!si->registereddone) =0A=
-      pthread_cond_wait(&(si->registered), &(si->registeredlock));=0A=
-    pthread_mutex_unlock(&(si->registeredlock));=0A=
+    if (0 =3D=3D result) {=0A=
+      si->registereddone =3D 0;=0A=
+      pthread_mutex_lock(&(si->registeredlock));=0A=
+      while (!si->registereddone) =0A=
+        pthread_cond_wait(&(si->registered), =
&(si->registeredlock));=0A=
+      pthread_mutex_unlock(&(si->registeredlock));=0A=
+    }=0A=
 =0A=
     pthread_cond_destroy(&(si->registered));=0A=
     pthread_mutex_destroy(&(si->registeredlock));=0A=

------_=_NextPart_000_01C340C4.CC2DB0E0--