From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Giorgos Keramidas Newsgroups: gmane.emacs.devel Subject: posix_memalign() and FreeBSD Date: Thu, 9 Mar 2006 18:11:42 +0200 Message-ID: <20060309161142.GA55193@flame.pc> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1141920851 28549 80.91.229.2 (9 Mar 2006 16:14:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 9 Mar 2006 16:14:11 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 09 17:14:09 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FHNlB-0002pE-10 for ged-emacs-devel@m.gmane.org; Thu, 09 Mar 2006 17:13:05 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FHNlA-00066g-2w for ged-emacs-devel@m.gmane.org; Thu, 09 Mar 2006 11:13:04 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FHNkh-0005y9-S0 for emacs-devel@gnu.org; Thu, 09 Mar 2006 11:12:35 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FHNkc-0005kI-9V for emacs-devel@gnu.org; Thu, 09 Mar 2006 11:12:34 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FHNkc-0005kF-1O for emacs-devel@gnu.org; Thu, 09 Mar 2006 11:12:30 -0500 Original-Received: from [62.1.205.36] (helo=igloo.linux.gr) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1FHNnh-0005P6-Rx for emacs-devel@gnu.org; Thu, 09 Mar 2006 11:15:42 -0500 Original-Received: from flame.pc (aris.bedc.ondsl.gr [62.103.39.226]) (authenticated bits=128) by igloo.linux.gr (8.13.5/8.13.5/Debian-3) with ESMTP id k29GBqPM005678 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 9 Mar 2006 18:12:13 +0200 Original-Received: from flame.pc (flame [127.0.0.1]) by flame.pc (8.13.4/8.13.4) with ESMTP id k29GBi52074754; Thu, 9 Mar 2006 18:11:44 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Original-Received: (from keramida@localhost) by flame.pc (8.13.4/8.13.4/Submit) id k29GBhVa074737; Thu, 9 Mar 2006 18:11:43 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Original-To: Stefan Monnier , emacs-devel@gnu.org Content-Disposition: inline X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (score=-3.476, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.92, BAYES_00 -2.60, UPPERCASE_25_50 0.00) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr 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:51409 Archived-At: Hi Stefan and all, I suspected that the fact that posix_memalign() use has to be manually disabled (or removed through autoconf) for FreeBSD, was caused by allocating memory with posix_memalign() but later freeing it with Emacs' own malloc()/free() implementation. This results in random crashes during "make bootstrap" for the HEAD of the CVS tree -- which usually happens pretty fast, i.e. when building the autoload list of some module. Disabling posix_memalign() when SYSTEM_MALLOC is not used, with the following patch fixes bootstrapping on FreeBSD/amd64 here. Since the internal GNU malloc() of Emacs doesn't support posix_memalign(), do you think this is a reasonable change, or should I revert it in my local tree and see if I can track down where memory is allocated with posix_memalign() and released with GNU malloc's free()? %%% begin emacs-posix-memalign.patch Index: alloc.c =================================================================== *** alloc.c (revision 88) --- alloc.c (working copy) *************** *** 948,954 **** #define ABLOCKS_BUSY(abase) ((abase)->blocks[0].abase) /* Pointer to the (not necessarily aligned) malloc block. */ ! #ifdef HAVE_POSIX_MEMALIGN #define ABLOCKS_BASE(abase) (abase) #else #define ABLOCKS_BASE(abase) \ --- 948,954 ---- #define ABLOCKS_BUSY(abase) ((abase)->blocks[0].abase) /* Pointer to the (not necessarily aligned) malloc block. */ ! #if SYSTEM_MALLOC && HAVE_POSIX_MEMALIGN #define ABLOCKS_BASE(abase) (abase) #else #define ABLOCKS_BASE(abase) \ *************** *** 989,995 **** mallopt (M_MMAP_MAX, 0); #endif ! #ifdef HAVE_POSIX_MEMALIGN { int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES); if (err) --- 989,995 ---- mallopt (M_MMAP_MAX, 0); #endif ! #if SYSTEM_MALLOC && HAVE_POSIX_MEMALIGN { int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES); if (err) *************** *** 1105,1111 **** } eassert ((aligned & 1) == aligned); eassert (i == (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1)); ! #ifdef HAVE_POSIX_MEMALIGN eassert ((unsigned long)ABLOCKS_BASE (abase) % BLOCK_ALIGN == 0); #endif free (ABLOCKS_BASE (abase)); --- 1105,1111 ---- } eassert ((aligned & 1) == aligned); eassert (i == (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1)); ! #if SYSTEM_MALLOC && HAVE_POSIX_MEMALIGN eassert ((unsigned long)ABLOCKS_BASE (abase) % BLOCK_ALIGN == 0); #endif free (ABLOCKS_BASE (abase)); %%% end emacs-posix-memalign.patch - Giorgos