use MALLOC_PERTURB_ ... or lose

David Malcolm dmalcolm at
Wed May 5 14:14:28 UTC 2010

On Wed, 2010-05-05 at 11:01 +0200, Jim Meyering wrote:
> If you are into development on glibc-based systems
> and do not set MALLOC_PERTURB_ to a nonzero value, then you
> are missing an easy opportunity to detect subtle bugs early.
> Sure, you can use valgrind, and it will detect whatever a
> MALLOC_PERTURB_ setting would have caught, and more, but it's
> far more expensive and takes some effort, however minimal.
> If you use zsh or bash, put this in one of your startup files:
>     #
>     export MALLOC_PERTURB_=$(($RANDOM % 255 + 1))
> and remember that when you find surprising bugs, that others
> who are also running tests (but without MALLOC_PERTURB_)
> will not see the same failures.
> This is useful enough that it is worth considering for inclusion
> in /etc/profile.

If I'm reading how bash starts up correctly, potentially, we could have
file, perhaps owned by a malloc-perturb.rpm (perhaps a subpackage of
glibc?  glibc-malloc-perturb) - installing the rpm would give you an
opt-in for whole-system memory debugging.  Might be useful for the
automated QA systems, and for development hosts.

Hope this is helpful

More information about the devel mailing list