emacs-devel
[Top][All Lists]
Advanced

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

Re: emacs-unicode-2 bootstrap on FreeBSD (temacs coredump)


From: Jan Djärv
Subject: Re: emacs-unicode-2 bootstrap on FreeBSD (temacs coredump)
Date: Wed, 01 Aug 2007 13:53:57 +0200
User-agent: Thunderbird 2.0.0.5 (X11/20070719)



YAMAMOTO Mitsuharu skrev:
On Wed, 01 Aug 2007 19:07:47 +0900, YAMAMOTO Mitsuharu <address@hidden> said:

It might be possible to call pthread_mutex_init for all malloc
mutexes at the (non-thread-safe) initialization stage with
temporarily disabling the use of the mutexes.

Could you try if this works?  As usual, I can't test it myself.

I think we should call LOCK/UNLOCK on them also just to be sure.
You never know what those BDS guys are up to :-)

        Jan D.


                                     YAMAMOTO Mitsuharu
                                address@hidden

Index: src/gmalloc.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/gmalloc.c,v
retrieving revision 1.24
diff -c -p -r1.24 gmalloc.c
*** src/gmalloc.c       29 Jul 2007 10:12:21 -0000      1.24
--- src/gmalloc.c       1 Aug 2007 10:35:05 -0000
*************** extern void _free_internal_nolock PP ((_
*** 242,249 ****
#ifdef USE_PTHREAD
  extern pthread_mutex_t _malloc_mutex, _aligned_blocks_mutex;
! #define LOCK()     pthread_mutex_lock (&_malloc_mutex)
! #define UNLOCK()   pthread_mutex_unlock (&_malloc_mutex)
  #define LOCK_ALIGNED_BLOCKS()     pthread_mutex_lock (&_aligned_blocks_mutex)
  #define UNLOCK_ALIGNED_BLOCKS()   pthread_mutex_unlock 
(&_aligned_blocks_mutex)
  #else
--- 242,256 ----
#ifdef USE_PTHREAD
  extern pthread_mutex_t _malloc_mutex, _aligned_blocks_mutex;
! extern int _malloc_mutex_disabled_p;
! #define LOCK() \
!   do { \
!     if (!_malloc_mutex_disabled_p) pthread_mutex_lock (&_malloc_mutex); \
!   } while (0)
! #define UNLOCK() \
!   do { \
!     if (!_malloc_mutex_disabled_p) pthread_mutex_unlock (&_malloc_mutex); \
!   } while (0)
  #define LOCK_ALIGNED_BLOCKS()     pthread_mutex_lock (&_aligned_blocks_mutex)
  #define UNLOCK_ALIGNED_BLOCKS()   pthread_mutex_unlock 
(&_aligned_blocks_mutex)
  #else
*************** register_heapinfo ()
*** 563,568 ****
--- 570,576 ----
  #ifdef USE_PTHREAD
  pthread_mutex_t _malloc_mutex = PTHREAD_MUTEX_INITIALIZER;
  pthread_mutex_t _aligned_blocks_mutex = PTHREAD_MUTEX_INITIALIZER;
+ int _malloc_mutex_disabled_p;
  #endif
static void
*************** __malloc_initialize ()
*** 617,622 ****
--- 625,641 ----
malloc_initialize_1 (); + /* Some pthread implementations call malloc for statically
+      initialized mutexes when they are used first.  To avoid such a
+      situation, we initialize mutexes here with temporarily disabling
+      the use of mutexes.  */
+ #ifdef USE_PTHREAD
+   _malloc_mutex_disabled_p = 1;
+   pthread_mutex_init (&_malloc_mutex, NULL);
+   pthread_mutex_init (&_aligned_blocks_mutex, NULL);
+   _malloc_mutex_disabled_p = 0;
+ #endif
+ return __malloc_initialized;
  }

_______________________________________________
Emacs-devel mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/emacs-devel




reply via email to

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