emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-24 r117441: * src/gmalloc.c (_malloc_mutex, _aligned


From: Ken Brown
Subject: [Emacs-diffs] emacs-24 r117441: * src/gmalloc.c (_malloc_mutex, _aligned_blocks_mutex) [CYGWIN]: Use ERRORCHECK mutexes. (Bug#18222)
Date: Mon, 11 Aug 2014 15:26:50 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117441
revision-id: address@hidden
parent: address@hidden
committer: Ken Brown <address@hidden>
branch nick: emacs-24
timestamp: Mon 2014-08-11 11:25:08 -0400
message:
  * src/gmalloc.c (_malloc_mutex, _aligned_blocks_mutex) [CYGWIN]: Use 
ERRORCHECK mutexes.  (Bug#18222)
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/gmalloc.c                  gmalloc.c-20091113204419-o5vbwnq5f7feedwu-1085
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-08-11 00:38:19 +0000
+++ b/src/ChangeLog     2014-08-11 15:25:08 +0000
@@ -1,3 +1,8 @@
+2014-08-11  Ken Brown  <address@hidden>
+
+       * gmalloc.c (_malloc_mutex, _aligned_blocks_mutex) [CYGWIN]: Use
+       ERRORCHECK mutexes.  (Bug#18222)
+
 2014-08-11  Glenn Morris  <address@hidden>
 
        * fileio.c: Revert 2013-01-31 change, which chose coding system for

=== modified file 'src/gmalloc.c'
--- a/src/gmalloc.c     2014-03-04 19:02:49 +0000
+++ b/src/gmalloc.c     2014-08-11 15:25:08 +0000
@@ -490,8 +490,18 @@
 }
 
 #ifdef USE_PTHREAD
+/* On Cygwin prior to 1.7.31, pthread_mutexes were ERRORCHECK mutexes
+   by default.  When the default changed to NORMAL in Cygwin-1.7.31,
+   deadlocks occurred (bug#18222).  As a temporary workaround, we
+   explicitly set the mutexes to be of ERRORCHECK type, restoring the
+   previous behavior.  */
+#ifdef CYGWIN
+pthread_mutex_t _malloc_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
+pthread_mutex_t _aligned_blocks_mutex = 
PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
+#else  /* not CYGWIN */
 pthread_mutex_t _malloc_mutex = PTHREAD_MUTEX_INITIALIZER;
 pthread_mutex_t _aligned_blocks_mutex = PTHREAD_MUTEX_INITIALIZER;
+#endif /* not CYGWIN */
 int _malloc_thread_enabled_p;
 
 static void
@@ -526,14 +536,23 @@
      initialized mutexes when they are used first.  To avoid such a
      situation, we initialize mutexes here while their use is
      disabled in malloc etc.  */
+#ifdef CYGWIN
+  /* Use ERRORCHECK mutexes; see comment above. */
+  pthread_mutexattr_t attr;
+  pthread_mutexattr_init (&attr);
+  pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_ERRORCHECK);
+  pthread_mutex_init (&_malloc_mutex, &attr);
+  pthread_mutex_init (&_aligned_blocks_mutex, &attr);
+#else  /* not CYGWIN */
   pthread_mutex_init (&_malloc_mutex, NULL);
   pthread_mutex_init (&_aligned_blocks_mutex, NULL);
+#endif /* not CYGWIN */
   pthread_atfork (malloc_atfork_handler_prepare,
                  malloc_atfork_handler_parent,
                  malloc_atfork_handler_child);
   _malloc_thread_enabled_p = 1;
 }
-#endif
+#endif /* USE_PTHREAD */
 
 static void
 malloc_initialize_1 (void)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]