Memcached crashing on FreeBSD

Jason Coene jcoene at gotfrag.com
Mon Apr 11 10:53:13 PDT 2005


Interesting stuff... As for the malloc options, I'm running the defaults.  I
suspect nearly every other FreeBSD user is as well.  I wasn't aware of the
FreeBSD default behavior, or the option to change it.  It does sound like
this might be a good thing for configure to look for - I'm surprised nobody
has run in to it yet.

In FreeBSD, _malloc_options is defined in /usr/include/stdlib.h as:

extern const char *_malloc_options;

I've added the following and re-compiled.  My #define picks up locally, but
my C is rusty and it's been too long for me to know whether or not the
library will get it.  Hopefully it will, or maybe someone else knows the
proper way to do this.  A direct assignment of _malloc_options="ax"; won't
compile.

--

Added to config.h:

/* FreeBSD (and others?) should have A and X malloc options turned off */
#define MALLOC_OPTIONS "ax"

--

Added to memcached.h:

#ifdef MALLOC_OPTIONS
#define _malloc_options MALLOC_OPTIONS
#endif

--

Thanks,

Jason

> -----Original Message-----
> From: memcached-bounces at lists.danga.com [mailto:memcached-
> bounces at lists.danga.com] On Behalf Of Anatoly Vorobey
> Sent: Monday, April 11, 2005 12:50 PM
> To: memcached at lists.danga.com
> Subject: Re: Memcached crashing on FreeBSD
> 
> On Mon, Apr 11, 2005 at 09:37:40AM -0700, Brad Fitzpatrick wrote:
> > On Mon, 11 Apr 2005, Anatoly Vorobey wrote:
> >
> > > It's normal for memcache to fail to allocate a new slab with
> > > malloc(); in this case malloc() should just return an error, but
> > > it aborts on your system, probably due to your configuration of
> > > /etc/malloc.conf . See malloc(3). You can try running memcached
> > > with MALLOC_OPTIONS set to "a"; that should override your
> > > /etc/malloc.conf settings if that's the problem.
> >
> > Can a program change the a/A flag, essentially telling libc that we can
> > handle memory failures gracefully?
> 
> Yes, I think that's what the _malloc_options global variable is for;
> see
> http://www.freebsd.org/cgi/man.cgi?query=malloc&apropos=0&sektion=0&manpat
> h=FreeBSD+5.3-RELEASE+and+Ports&format=html
> 
> We could do something like _malloc_options="a";  guarded by #ifdef's
> for FreeBSD. It seems like this would solve the problem, although I
> don't have a ready access to a FreeBSD box to try it.
> 
> [or maybe "ax", seeing as the "X" option also causes malloc to abort
> in case allocation fails. Yes, _malloc_options="ax" seems like the
> thing to try].
> 
> --
> avva
> "There's nothing simply good, nor ill alone" -- John Donne




More information about the memcached mailing list