aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKen Brown2014-08-11 11:25:08 -0400
committerKen Brown2014-08-11 11:25:08 -0400
commit2b0cb8b177eff6a4aaf14f5c728be3f22aa4b75e (patch)
tree31255c1b4e5a76fdc35c51e1bc7f625d9e839bc9 /src
parent727f37e6cc0f0147c2b316422cfd6f80edf0e7fd (diff)
downloademacs-2b0cb8b177eff6a4aaf14f5c728be3f22aa4b75e.tar.gz
emacs-2b0cb8b177eff6a4aaf14f5c728be3f22aa4b75e.zip
* src/gmalloc.c (_malloc_mutex, _aligned_blocks_mutex) [CYGWIN]: Use ERRORCHECK mutexes. (Bug#18222)
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/gmalloc.c21
2 files changed, 25 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 92d90accc60..628fa26d778 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12014-08-11 Ken Brown <kbrown@cornell.edu>
2
3 * gmalloc.c (_malloc_mutex, _aligned_blocks_mutex) [CYGWIN]: Use
4 ERRORCHECK mutexes. (Bug#18222)
5
12014-08-11 Glenn Morris <rgm@gnu.org> 62014-08-11 Glenn Morris <rgm@gnu.org>
2 7
3 * fileio.c: Revert 2013-01-31 change, which chose coding system for 8 * fileio.c: Revert 2013-01-31 change, which chose coding system for
diff --git a/src/gmalloc.c b/src/gmalloc.c
index 977abbdbbbd..0e90b5a3498 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -490,8 +490,18 @@ register_heapinfo (void)
490} 490}
491 491
492#ifdef USE_PTHREAD 492#ifdef USE_PTHREAD
493/* On Cygwin prior to 1.7.31, pthread_mutexes were ERRORCHECK mutexes
494 by default. When the default changed to NORMAL in Cygwin-1.7.31,
495 deadlocks occurred (bug#18222). As a temporary workaround, we
496 explicitly set the mutexes to be of ERRORCHECK type, restoring the
497 previous behavior. */
498#ifdef CYGWIN
499pthread_mutex_t _malloc_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
500pthread_mutex_t _aligned_blocks_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
501#else /* not CYGWIN */
493pthread_mutex_t _malloc_mutex = PTHREAD_MUTEX_INITIALIZER; 502pthread_mutex_t _malloc_mutex = PTHREAD_MUTEX_INITIALIZER;
494pthread_mutex_t _aligned_blocks_mutex = PTHREAD_MUTEX_INITIALIZER; 503pthread_mutex_t _aligned_blocks_mutex = PTHREAD_MUTEX_INITIALIZER;
504#endif /* not CYGWIN */
495int _malloc_thread_enabled_p; 505int _malloc_thread_enabled_p;
496 506
497static void 507static void
@@ -526,14 +536,23 @@ malloc_enable_thread (void)
526 initialized mutexes when they are used first. To avoid such a 536 initialized mutexes when they are used first. To avoid such a
527 situation, we initialize mutexes here while their use is 537 situation, we initialize mutexes here while their use is
528 disabled in malloc etc. */ 538 disabled in malloc etc. */
539#ifdef CYGWIN
540 /* Use ERRORCHECK mutexes; see comment above. */
541 pthread_mutexattr_t attr;
542 pthread_mutexattr_init (&attr);
543 pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_ERRORCHECK);
544 pthread_mutex_init (&_malloc_mutex, &attr);
545 pthread_mutex_init (&_aligned_blocks_mutex, &attr);
546#else /* not CYGWIN */
529 pthread_mutex_init (&_malloc_mutex, NULL); 547 pthread_mutex_init (&_malloc_mutex, NULL);
530 pthread_mutex_init (&_aligned_blocks_mutex, NULL); 548 pthread_mutex_init (&_aligned_blocks_mutex, NULL);
549#endif /* not CYGWIN */
531 pthread_atfork (malloc_atfork_handler_prepare, 550 pthread_atfork (malloc_atfork_handler_prepare,
532 malloc_atfork_handler_parent, 551 malloc_atfork_handler_parent,
533 malloc_atfork_handler_child); 552 malloc_atfork_handler_child);
534 _malloc_thread_enabled_p = 1; 553 _malloc_thread_enabled_p = 1;
535} 554}
536#endif 555#endif /* USE_PTHREAD */
537 556
538static void 557static void
539malloc_initialize_1 (void) 558malloc_initialize_1 (void)