public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] test-skeleton.c: Do not enable M_PERTURB
@ 2016-06-23 14:40 Florian Weimer
  2016-06-23 14:50 ` Siddhesh Poyarekar
  0 siblings, 1 reply; 10+ messages in thread
From: Florian Weimer @ 2016-06-23 14:40 UTC (permalink / raw)
  To: libc-alpha

Over all, this decreases the realism of the tests because
it ensures that freshly allocated memory has a well-defined
bit pattern.  It also causes malloc to take internal paths
different from regular application usage, and therefore
reduces malloc test coverage.

2016-06-23  Florian Weimer  <fweimer@redhat.com>

	* test-skeleton.c (main): Do not enable M_PERTURB.

diff --git a/test-skeleton.c b/test-skeleton.c
index d9bf989..e462eee 100644
--- a/test-skeleton.c
+++ b/test-skeleton.c
@@ -346,9 +346,6 @@ main (int argc, char *argv[])
   unsigned int timeoutfactor = 1;
   pid_t termpid;
 
-  /* Make uses of freed and uninitialized memory known.  */
-  mallopt (M_PERTURB, 42);
-
 #ifdef STDOUT_UNBUFFERED
   setbuf (stdout, NULL);
 #endif

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] test-skeleton.c: Do not enable M_PERTURB
  2016-06-23 14:40 [PATCH] test-skeleton.c: Do not enable M_PERTURB Florian Weimer
@ 2016-06-23 14:50 ` Siddhesh Poyarekar
  2016-06-23 15:05   ` Florian Weimer
  0 siblings, 1 reply; 10+ messages in thread
From: Siddhesh Poyarekar @ 2016-06-23 14:50 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

On Thu, Jun 23, 2016 at 04:40:42PM +0200, Florian Weimer wrote:
> Over all, this decreases the realism of the tests because
> it ensures that freshly allocated memory has a well-defined
> bit pattern.  It also causes malloc to take internal paths
> different from regular application usage, and therefore
> reduces malloc test coverage.

The well-defined bit pattern is more likely to catch any bad tests
though, which might make it valuable.  However, I agree that it makes
sense to remove it for malloc tests.

Siddhesh

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] test-skeleton.c: Do not enable M_PERTURB
  2016-06-23 14:50 ` Siddhesh Poyarekar
@ 2016-06-23 15:05   ` Florian Weimer
  2016-06-23 16:00     ` Siddhesh Poyarekar
  2016-06-23 19:31     ` Mike Frysinger
  0 siblings, 2 replies; 10+ messages in thread
From: Florian Weimer @ 2016-06-23 15:05 UTC (permalink / raw)
  To: Siddhesh Poyarekar; +Cc: libc-alpha

On 06/23/2016 04:49 PM, Siddhesh Poyarekar wrote:
> On Thu, Jun 23, 2016 at 04:40:42PM +0200, Florian Weimer wrote:
>> Over all, this decreases the realism of the tests because
>> it ensures that freshly allocated memory has a well-defined
>> bit pattern.  It also causes malloc to take internal paths
>> different from regular application usage, and therefore
>> reduces malloc test coverage.
>
> The well-defined bit pattern is more likely to catch any bad tests
> though, which might make it valuable.

It could also cover up bugs which would otherwise be visible with fresh 
allocations which contain only zeros.

Ideally, we'd run all tests twice, with different settings from the 
environment (and also with valgrind).

Thanks,
Florian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] test-skeleton.c: Do not enable M_PERTURB
  2016-06-23 15:05   ` Florian Weimer
@ 2016-06-23 16:00     ` Siddhesh Poyarekar
  2016-06-23 16:57       ` Zack Weinberg
  2016-06-23 19:31     ` Mike Frysinger
  1 sibling, 1 reply; 10+ messages in thread
From: Siddhesh Poyarekar @ 2016-06-23 16:00 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

On Thu, Jun 23, 2016 at 05:05:33PM +0200, Florian Weimer wrote:
> It could also cover up bugs which would otherwise be visible with fresh
> allocations which contain only zeros.
> 
> Ideally, we'd run all tests twice, with different settings from the
> environment (and also with valgrind).

Yeah, if you were to do that kind of coverage at the distribution
level (i.e. run the tests twice, once with and then without valgrind)
that the change makes sense to make the tests behave as closely as
possible to the real world.

In short, LGTM.

Siddhesh

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] test-skeleton.c: Do not enable M_PERTURB
  2016-06-23 16:00     ` Siddhesh Poyarekar
@ 2016-06-23 16:57       ` Zack Weinberg
  2016-06-23 17:17         ` Siddhesh Poyarekar
  0 siblings, 1 reply; 10+ messages in thread
From: Zack Weinberg @ 2016-06-23 16:57 UTC (permalink / raw)
  To: Siddhesh Poyarekar; +Cc: Florian Weimer, GNU C Library

On Thu, Jun 23, 2016 at 12:00 PM, Siddhesh Poyarekar
<siddhesh@sourceware.org> wrote:
> On Thu, Jun 23, 2016 at 05:05:33PM +0200, Florian Weimer wrote:
>> It could also cover up bugs which would otherwise be visible with fresh
>> allocations which contain only zeros.
>>
>> Ideally, we'd run all tests twice, with different settings from the
>> environment (and also with valgrind).
>
> Yeah, if you were to do that kind of coverage at the distribution
> level (i.e. run the tests twice, once with and then without valgrind)
> that the change makes sense to make the tests behave as closely as
> possible to the real world.

Is there a well-documented way to run the tests under valgrind?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] test-skeleton.c: Do not enable M_PERTURB
  2016-06-23 16:57       ` Zack Weinberg
@ 2016-06-23 17:17         ` Siddhesh Poyarekar
  2016-06-23 17:25           ` Florian Weimer
  0 siblings, 1 reply; 10+ messages in thread
From: Siddhesh Poyarekar @ 2016-06-23 17:17 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: Florian Weimer, GNU C Library

On Thu, Jun 23, 2016 at 12:57:17PM -0400, Zack Weinberg wrote:
> Is there a well-documented way to run the tests under valgrind?

I don't think so, but it ought to be sufficient to run valgrind
--trace-children=yes for all of make check.  Dead slow, but I don't
see why it shouldn't work.

Maybe this is a good candidate for enhancement in glibc to allow
running individual tests under valgrind, something like
'make valgrind-check'.

Siddhesh

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] test-skeleton.c: Do not enable M_PERTURB
  2016-06-23 17:17         ` Siddhesh Poyarekar
@ 2016-06-23 17:25           ` Florian Weimer
  2016-06-23 19:30             ` Mike Frysinger
  0 siblings, 1 reply; 10+ messages in thread
From: Florian Weimer @ 2016-06-23 17:25 UTC (permalink / raw)
  To: Siddhesh Poyarekar, Zack Weinberg; +Cc: GNU C Library

On 06/23/2016 07:16 PM, Siddhesh Poyarekar wrote:
> On Thu, Jun 23, 2016 at 12:57:17PM -0400, Zack Weinberg wrote:
>> Is there a well-documented way to run the tests under valgrind?
>
> I don't think so, but it ought to be sufficient to run valgrind
> --trace-children=yes for all of make check.  Dead slow, but I don't
> see why it shouldn't work.
>
> Maybe this is a good candidate for enhancement in glibc to allow
> running individual tests under valgrind, something like
> 'make valgrind-check'.

Running tests under valgrind is one thing.  Interpreting the errors is 
another.

On some architectures, running valgrind on a non-installed libc gives 
rather poor results.  Some versions do not recognize malloc as such, and 
on some architectures, the suppression files are inactive because the 
libc paths do not match the hard-coded expectations of valgrind.

With certain tests, we have the problem that we have memory leaks when 
subprocesses call exit, without freeing data, which is marked as a leak 
in the error log.

Thread stack deallocation is generally racy, and stacks may be reported 
by valgrind as a memory leak.

These are just the issues I have seen so far when running valgrind 
manually.  I expect there are more.

Thanks,
Florian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] test-skeleton.c: Do not enable M_PERTURB
  2016-06-23 17:25           ` Florian Weimer
@ 2016-06-23 19:30             ` Mike Frysinger
  0 siblings, 0 replies; 10+ messages in thread
From: Mike Frysinger @ 2016-06-23 19:30 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Siddhesh Poyarekar, Zack Weinberg, GNU C Library

[-- Attachment #1: Type: text/plain, Size: 1191 bytes --]

On 23 Jun 2016 19:25, Florian Weimer wrote:
> On 06/23/2016 07:16 PM, Siddhesh Poyarekar wrote:
> > On Thu, Jun 23, 2016 at 12:57:17PM -0400, Zack Weinberg wrote:
> >> Is there a well-documented way to run the tests under valgrind?
> >
> > I don't think so, but it ought to be sufficient to run valgrind
> > --trace-children=yes for all of make check.  Dead slow, but I don't
> > see why it shouldn't work.
> >
> > Maybe this is a good candidate for enhancement in glibc to allow
> > running individual tests under valgrind, something like
> > 'make valgrind-check'.
> 
> Running tests under valgrind is one thing.  Interpreting the errors is 
> another.
> 
> On some architectures, running valgrind on a non-installed libc gives 
> rather poor results.  Some versions do not recognize malloc as such, and 
> on some architectures, the suppression files are inactive because the 
> libc paths do not match the hard-coded expectations of valgrind.

not only that, but valgrind frequently needs to be updated whenever a new
glibc release is made (to tweak internal false positives).  if we tried to
use that against git master, i'm afraid it'd always be broken.
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] test-skeleton.c: Do not enable M_PERTURB
  2016-06-23 15:05   ` Florian Weimer
  2016-06-23 16:00     ` Siddhesh Poyarekar
@ 2016-06-23 19:31     ` Mike Frysinger
  2016-06-24 10:50       ` Florian Weimer
  1 sibling, 1 reply; 10+ messages in thread
From: Mike Frysinger @ 2016-06-23 19:31 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Siddhesh Poyarekar, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 969 bytes --]

On 23 Jun 2016 17:05, Florian Weimer wrote:
> On 06/23/2016 04:49 PM, Siddhesh Poyarekar wrote:
> > On Thu, Jun 23, 2016 at 04:40:42PM +0200, Florian Weimer wrote:
> >> Over all, this decreases the realism of the tests because
> >> it ensures that freshly allocated memory has a well-defined
> >> bit pattern.  It also causes malloc to take internal paths
> >> different from regular application usage, and therefore
> >> reduces malloc test coverage.
> >
> > The well-defined bit pattern is more likely to catch any bad tests
> > though, which might make it valuable.
> 
> It could also cover up bugs which would otherwise be visible with fresh 
> allocations which contain only zeros.

while certainly true, i think this is much less common of an edge case.
code that happens to work because it happened to get zero-ed memory is,
in my experience, way less common than code that happens to work because
it happened to get garbage initially.
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] test-skeleton.c: Do not enable M_PERTURB
  2016-06-23 19:31     ` Mike Frysinger
@ 2016-06-24 10:50       ` Florian Weimer
  0 siblings, 0 replies; 10+ messages in thread
From: Florian Weimer @ 2016-06-24 10:50 UTC (permalink / raw)
  To: Siddhesh Poyarekar, libc-alpha

On 06/23/2016 09:31 PM, Mike Frysinger wrote:
> On 23 Jun 2016 17:05, Florian Weimer wrote:
>> On 06/23/2016 04:49 PM, Siddhesh Poyarekar wrote:
>>> On Thu, Jun 23, 2016 at 04:40:42PM +0200, Florian Weimer wrote:
>>>> Over all, this decreases the realism of the tests because
>>>> it ensures that freshly allocated memory has a well-defined
>>>> bit pattern.  It also causes malloc to take internal paths
>>>> different from regular application usage, and therefore
>>>> reduces malloc test coverage.
>>>
>>> The well-defined bit pattern is more likely to catch any bad tests
>>> though, which might make it valuable.
>>
>> It could also cover up bugs which would otherwise be visible with fresh
>> allocations which contain only zeros.
>
> while certainly true, i think this is much less common of an edge case.
> code that happens to work because it happened to get zero-ed memory is,
> in my experience, way less common than code that happens to work because
> it happened to get garbage initially.

Okay, patch withdrawn.

Thanks,
Florian

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-06-24 10:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-23 14:40 [PATCH] test-skeleton.c: Do not enable M_PERTURB Florian Weimer
2016-06-23 14:50 ` Siddhesh Poyarekar
2016-06-23 15:05   ` Florian Weimer
2016-06-23 16:00     ` Siddhesh Poyarekar
2016-06-23 16:57       ` Zack Weinberg
2016-06-23 17:17         ` Siddhesh Poyarekar
2016-06-23 17:25           ` Florian Weimer
2016-06-23 19:30             ` Mike Frysinger
2016-06-23 19:31     ` Mike Frysinger
2016-06-24 10:50       ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).