From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: YAMAMOTO Mitsuharu Newsgroups: gmane.emacs.devel Subject: Re: emacs-unicode-2 bootstrap on FreeBSD (temacs coredump) Date: Wed, 01 Aug 2007 19:42:31 +0900 Organization: Faculty of Science, Chiba University Message-ID: References: <46AA17BD.7080900@netasq.com> <46AC6849.1010400@swipnet.se> <20070731190955.GA11917@oslo.ath.cx> <46B0505A.9010208@swipnet.se> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Trace: sea.gmane.org 1185964969 9351 80.91.229.12 (1 Aug 2007 10:42:49 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 1 Aug 2007 10:42:49 +0000 (UTC) Cc: "Herbert J. Skuhra" , emacs-devel@gnu.org To: Jan =?ISO-8859-1?Q?Dj=E4rv?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Aug 01 12:42:43 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IGBf5-0007dP-Fy for ged-emacs-devel@m.gmane.org; Wed, 01 Aug 2007 12:42:39 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IGBf4-0007XU-NL for ged-emacs-devel@m.gmane.org; Wed, 01 Aug 2007 06:42:38 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IGBf1-0007W7-7p for emacs-devel@gnu.org; Wed, 01 Aug 2007 06:42:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IGBf0-0007Vv-9h for emacs-devel@gnu.org; Wed, 01 Aug 2007 06:42:34 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IGBf0-0007Vs-5O for emacs-devel@gnu.org; Wed, 01 Aug 2007 06:42:34 -0400 Original-Received: from mathmail.math.s.chiba-u.ac.jp ([133.82.132.2]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IGBez-0002kL-IS for emacs-devel@gnu.org; Wed, 01 Aug 2007 06:42:34 -0400 Original-Received: from church.math.s.chiba-u.ac.jp (church [133.82.132.36]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id 9A79D2C40; Wed, 1 Aug 2007 19:42:31 +0900 (JST) In-Reply-To: User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 Emacs/22.1.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) X-Detected-Kernel: NetBSD 3.0 (DF) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:75898 Archived-At: >>>>> On Wed, 01 Aug 2007 19:07:47 +0900, YAMAMOTO Mitsuharu 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. YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp 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; }