X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Message-ID: <4A24FD89.8090105@gmail.com> Date: Tue, 02 Jun 2009 11:23:05 +0100 From: Dave Korn User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: [1.7] pthread_create block References: <9bfd07db0906020210h57d4c12h62f47a6ba3a5730e AT mail DOT gmail DOT com> In-Reply-To: <9bfd07db0906020210h57d4c12h62f47a6ba3a5730e@mail.gmail.com> Content-Type: multipart/mixed; boundary="------------030804020300020409010901" Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com --------------030804020300020409010901 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Thomas Stalder wrote: > Sometimes pthread_create block and never return. > > I have made a simple program (test.c) to reproduce the problem. > >> gcc test.c -lpthread -o test >> ./test > thread id=1 > thread id=2 > thread id=3 > thread id=4 > ........ > thread id=3736 > > > Sometimes pthread_create block after creating arround 10 threads, > sometimes after creating arround 10000 threads or more. You may have run into the pthread interlocking bug that I'm tracking down in this thread on the cygwin-dev list: http://www.cygwin.com/ml/cygwin-developers/2009-05/threads.html#00084 If you'd like to try building the cygwin DLL yourself from the CVS sources with the attached patch applied, you may find it solves your problem; at least for me it does. I've been running your test program while writing this email and it's got as far as this: thread id=1260546 thread id=1260547 ... without a hiccup. Actually, now it's got as far as thread id=2405875 by the time I diff'd the patch for you. (If you'd prefer, I could send you a binary of the DLL built with the patch, off-list; let me know). cheers, DaveK --------------030804020300020409010901 Content-Type: text/x-c; name="asm-interlock.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="asm-interlock.diff" Index: winsup/cygwin/winbase.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/winbase.h,v retrieving revision 1.14 diff -p -u -r1.14 winbase.h --- winsup/cygwin/winbase.h 12 Jul 2008 18:09:17 -0000 1.14 +++ winsup/cygwin/winbase.h 2 Jun 2009 10:06:17 -0000 @@ -38,21 +38,21 @@ ilockdecr (volatile long *m) extern __inline__ long ilockexch (volatile long *t, long v) { - register int __res; + register long __res __asm__ ("%eax") = *t; __asm__ __volatile__ ("\n\ -1: lock cmpxchgl %3,(%1)\n\ +1: lock cmpxchgl %2,%1\n\ jne 1b\n\ - ": "=a" (__res), "=q" (t): "1" (t), "q" (v), "0" (*t): "cc"); + ": "+a" (__res), "=m" (*t): "q" (v), "m" (*t) : "memory", "cc"); return __res; } extern __inline__ long ilockcmpexch (volatile long *t, long v, long c) { - register int __res; + register long __res __asm ("%eax") = c; __asm__ __volatile__ ("\n\ - lock cmpxchgl %3,(%1)\n\ - ": "=a" (__res), "=q" (t) : "1" (t), "q" (v), "0" (c): "cc"); + lock cmpxchgl %2,%1\n\ + ": "+a" (__res), "=m" (*t) : "q" (v), "m" (*t) : "memory", "cc"); return __res; } --------------030804020300020409010901 Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ --------------030804020300020409010901--