From: Giorgos Keramidas <keramida@ceid.upatras.gr>
Subject: posix_memalign() and FreeBSD
Date: Thu, 9 Mar 2006 18:11:42 +0200 [thread overview]
Message-ID: <20060309161142.GA55193@flame.pc> (raw)
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
next reply other threads:[~2006-03-09 16:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-09 16:11 Giorgos Keramidas [this message]
2006-03-09 18:59 ` posix_memalign() and FreeBSD Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060309161142.GA55193@flame.pc \
--to=keramida@ceid.upatras.gr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.