use MALLOC_PERTURB_ ... or lose

Jim Meyering jim at
Wed May 5 09:01:29 UTC 2010

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.

More information about the devel mailing list