-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 30.04.2013 19:18, xunxun wrote:
> 于 2013/4/24 星期三 19:12, LRN 写道:
>> msgmerge.exe (from gettext, i guess) hangs up, consuming 100% of a CPU
>> core, this is the backtrace:
>> #0  0x74d53b64 in SleepEx () from C:\Windows\syswow64\KernelBase.dll
>> #1  0x74d54498 in Sleep () from C:\Windows\syswow64\KernelBase.dll
>> #2  0x6494406b in _spin_lite_lock (l=0x64943003 <mutex_ref+19>) at
>> ../winpthreads-svn-r5792/src/spinlock.c:256
>> #3  0x00000001 in ?? ()
>> #4  0x64943003 in mutex_ref (m=0x11, m@entry=0x534fb4) at
>> ../winpthreads-svn-r5792/src/mutex.c:60
>> #5  0x6494317f in pthread_mutex_lock_intern (timeout=4294967295,
>> m=0x534fb4) at ../winpthreads-svn-r5792/src/mutex.c:236
>> #6  pthread_mutex_lock (m=m@entry=0x534fb4) at
>> ../winpthreads-svn-r5792/src/mutex.c:223
>> #7  0x64943482 in rwlock_gain_both_locks
>> (rwlock=rwlock@entry=0x534fa0) at
>> ../winpthreads-svn-r5792/src/rwlock.c:107
>> #8  0x64943b5e in pthread_rwlock_wrlock
>> (rwlock_=rwlock_@entry=0x6494f08c) at
>> ../winpthreads-svn-r5792/src/rwlock.c:430
>> #9  0x64944f26 in pthread_key_delete (key=0) at
>> ../winpthreads-svn-r5792/src/thread.c:739
>> #10 0x6360da61 in team_destructor () from f:\s31\mingw\bin\libgomp-1.dll
>> #11 0x00000000 in ?? ()
>> 
>> I'm using an svn-r5792 version of winpthreads + libgomp patches from
>> ktietz.
> Where is the libgomp patches?

He pastebinned that patch at 2013-04-22 15:24:19 (that pastebin is
no longer alive, so i've attached the copy that i've got back then).
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)

iQEcBAEBAgAGBQJRgBe8AAoJEOs4Jb6SI2Cw5JkH/iXMAh3sNF/xo5em8WcnjAMz
Ew+ABAu53BBnw4Bxwvmyt/5tm7f6REhtxMPqwO8JcWDYtO05cWx7lV7VV+aTeldi
BNvbQMqwrvdr17VKVrTPkq1sTGTDpnB+rPs8eUfPy+B4bACvbj20x9cZMqbJY1ih
LZEeKWTvBgQ9DLb63BmKejem5XD34iITBmi5Vqh5+d8X/Knhnrb/Tk5XY2L0znI0
oMUL6ACblH2EI5uuCGNrL71oO9E2ysBJwtYYAa7UnNoma+2FZWdDdDH8Vf46Ed4g
HJc70GGp09sMi+vabVwUAI2/09J7a8NAF/WXTQ8NIJkpvhGvINIwpg9hrVUlze8=
=g7W6
-----END PGP SIGNATURE-----
Index: libgomp.h
===================================================================
--- a/libgomp/libgomp.h   (Revision 198124)
+++ b/libgomp/libgomp.h   (Arbeitskopie)
@@ -378,9 +378,20 @@ static inline struct gomp_thread *gomp_thread (voi
 }
 #else
 extern pthread_key_t gomp_tls_key;
+extern void initialize_team (void);
+extern void gomp_fatal (const char *, ...)
+       __attribute__((noreturn, format (printf, 1, 2)));
 static inline struct gomp_thread *gomp_thread (void)
 {
-  return pthread_getspecific (gomp_tls_key);
+  struct gomp_thread* GompThread = pthread_getspecific (gomp_tls_key);
+  if (!GompThread) {
+    initialize_team();
+    GompThread = pthread_getspecific (gomp_tls_key);
+    if (!GompThread) {
+      gomp_fatal("Uncorrectable NULL gomp_thread()");
+    }
+  }
+  return GompThread;
 }
 #endif
 
Index: team.c
===================================================================
--- a/libgomp/team.c      (Revision 198124)
+++ b/libgomp/team.c      (Arbeitskopie)
@@ -72,9 +72,12 @@ gomp_thread_start (void *xdata)
 #ifdef HAVE_TLS
   thr = &gomp_tls_data;
 #else
-  struct gomp_thread local_thr;
-  thr = &local_thr;
-  pthread_setspecific (gomp_tls_key, thr);
+  struct gomp_thread *Ptr_initial_thread_tls_data;
+  Ptr_initial_thread_tls_data =
+    (struct gomp_thread*) calloc(1,sizeof(struct gomp_thread));
+
+  if (!KeysCreated) pthread_key_create (&gomp_tls_key, NULL);
+  pthread_setspecific (gomp_tls_key, Ptr_initial_thread_tls_data);
 #endif
   gomp_sem_init (&thr->release, 0);
 
@@ -253,6 +256,9 @@ gomp_free_thread (void *arg __attribute__((unused)
       gomp_end_task ();
       free (task);
     }
+#ifndef HAVE_TLS
+  free(pthread_getspecific (gomp_tls_key));
+#endif
 }
 
 /* Launch a team.  */
@@ -529,25 +535,32 @@ gomp_team_end (void)
 
 /* Constructors for this file.  */
 
-static void __attribute__((constructor))
+static short KeysCreated = 0;
+
+void __attribute__((constructor))
 initialize_team (void)
 {
   struct gomp_thread *thr;
 
 #ifndef HAVE_TLS
-  static struct gomp_thread initial_thread_tls_data;
+  struct gomp_thread *Ptr_initial_thread_tls_data;
+  Ptr_initial_thread_tls_data =
+    (struct gomp_thread*) calloc(1,sizeof(struct gomp_thread));
 
-  pthread_key_create (&gomp_tls_key, NULL);
-  pthread_setspecific (gomp_tls_key, &initial_thread_tls_data);
+  if (!KeysCreated) pthread_key_create (&gomp_tls_key, NULL);
+  pthread_setspecific (gomp_tls_key, Ptr_initial_thread_tls_data);
 #endif
 
-  if (pthread_key_create (&gomp_thread_destructor, gomp_free_thread) != 0)
-    gomp_fatal ("could not create thread pool destructor.");
+  if (!KeysCreated &&
+      pthread_key_create (&gomp_thread_destructor, gomp_free_thread) != 0)
+      gomp_fatal ("could not create thread pool destructor.");
 
+  KeysCreated = 1;
+
 #ifdef HAVE_TLS
   thr = &gomp_tls_data;
 #else
-  thr = &initial_thread_tls_data;
+  thr = Ptr_initial_thread_tls_data;
 #endif
   gomp_sem_init (&thr->release, 0);
 }
Index: testsuite/config/default.exp
===================================================================
--- a/libgomp/testsuite/config/default.exp        (Revision 198124)
+++ b/libgomp/testsuite/config/default.exp        (Arbeitskopie)
@@ -15,3 +15,8 @@
 # <http://www.gnu.org/licenses/>.
 
 load_lib "standard.exp"
+
+# Support for old dejagnu.  Must be loaded here, not in libstdc++.exp, to
+# make sure all existing procs are loaded when their presence is tested.
+load_file $srcdir/../../gcc/testsuite/lib/dejapatches.exp
+
------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to