* posix_memalign() and FreeBSD
@ 2006-03-09 16:11 Giorgos Keramidas
2006-03-09 18:59 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: Giorgos Keramidas @ 2006-03-09 16:11 UTC (permalink / 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: posix_memalign() and FreeBSD
2006-03-09 16:11 posix_memalign() and FreeBSD Giorgos Keramidas
@ 2006-03-09 18:59 ` Stefan Monnier
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2006-03-09 18:59 UTC (permalink / raw)
Cc: emacs-devel
> Disabling posix_memalign() when SYSTEM_MALLOC is not used, with
> the following patch fixes bootstrapping on FreeBSD/amd64 here.
You're 100% right. I'll install a patch ASAP,
Stefan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-03-09 18:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-09 16:11 posix_memalign() and FreeBSD Giorgos Keramidas
2006-03-09 18:59 ` Stefan Monnier
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.