[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
posix_memalign() and FreeBSD
From: |
Giorgos Keramidas |
Subject: |
posix_memalign() and FreeBSD |
Date: |
Thu, 9 Mar 2006 18:11:42 +0200 |
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
- posix_memalign() and FreeBSD,
Giorgos Keramidas <=