Re: [PATCH] Add MALLOC_CHECK_ and MALLOC_PERTURB_ libc env to the test suite for detecting heap corruption

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

 



Elia Pinto <gitter.spiros@xxxxxxxxx> writes:

>>  - That "165" thing I mentioned earlier.
>
> Thank you so much for the comments, that's fine. A single
> consideration for  MALLOC_PERTURB.
>
> You can use any value between 1..255 for MALLOC_PERTURB_
> That chooses the byte that glibc will use to memset all freed buffers.
> In general it is defined as
>
>     export MALLOC_PERTURB_=$(($RANDOM % 255 + 1))
>
> (as drepper pointed out http://udrepper.livejournal.com/11429.html)

Drepper never recommends RANDOM there.

> 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.

Quite the contrary.  When you use a fixed pattern, it is easy which
other pieces of memory has uninitailized contents.  When you use a
random value, you sometimes get an error and sometimes the test
mysteriously pass, which does not help debugging.

openSUSE folks seem to use a fixed value for this exact reason of
repeatability of tests.

http://jaegerandi.blogspot.com/2012/01/finding-subtile-malloc-bugs.html

> So OK per the original expression?

No.

I am not convinced 165 is the perfect value, but I am fairly certain
any fixed value is better than using a random to deliberately worsen
repeatability of the tests.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]