[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: please set both MALLOC_PERTURB_ and MALLOC_CHECK_ envvars

From: Jim Meyering
Subject: Re: please set both MALLOC_PERTURB_ and MALLOC_CHECK_ envvars
Date: Sat, 28 May 2011 22:33:38 +0200

Chong Yidong wrote:

> Jim Meyering <address@hidden> writes:
>>> If you develop emacs, or even if you just build from sources regularly,
>>> on a glibc-based system, do us all a favor and build with these envvar
>>> settings:
>>>     export MALLOC_PERTURB_=$((RANDOM % 255 + 1))
>>>     export MALLOC_CHECK_=3
>>> Why?  Because that helps you expose malloc-related problems far earlier.
>>> I've found numerous bugs that way.
>> Most of that argument is valid, but I have to confess this time
>> a compiler problem appears to be at fault.
>> [...]
>>     gcc version 4.7.0 20110528 (experimental) (GCC)
>> everything works fine, and yes!, even with these envvar settings:
>>     MALLOC_PERTURB_=117
>>     MALLOC_CHECK_=3
>> So at least for a little while, I'll be using that.
> Maybe we should add these environment variables to the Hydra build.

Good idea.

> But
> what to use for MALLOC_PERTURB---117, or the value in your previous
> message?

You can use any value between 1..255 for MALLOC_PERTURB_
That chooses the byte that glibc will use to memset all freed buffers.
I set it like this in a shell start-up file:

    export MALLOC_PERTURB_=$(($RANDOM % 255 + 1))

Using a random value is slightly better than using a fixed one
in case your fixed value is someday just the right/wrong value
to mask a problem.  At least with a random value, if you rerun
the test in a different shell, the odds are good you won't use
the unfortunate setting again.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]