public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc/azanella/master-posix_clock] Linux: Use mmap instead of malloc in dirent/tst-getdents64 Date: Tue, 02 Jul 2019 17:25:00 -0000 [thread overview] Message-ID: <20190702172540.18372.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=507f55c05f30c9eb80faf2546ec635c338c039eb commit 507f55c05f30c9eb80faf2546ec635c338c039eb Author: Florian Weimer <fweimer@redhat.com> Date: Fri Jun 28 10:48:48 2019 +0200 Linux: Use mmap instead of malloc in dirent/tst-getdents64 malloc dirties the entire allocated memory region due to M_PERTURB in the test harness. Diff: --- ChangeLog | 6 ++++++ sysdeps/unix/sysv/linux/tst-getdents64.c | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e1d6327..65129ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2019-06-28 Florian Weimer <fweimer@redhat.com> + + * sysdeps/unix/sysv/linux/tst-getdents64.c (large_buffer_checks): + Use mmap instead of malloc. malloc with M_PERTURB writes to the + entire allocated memory range. + 2019-06-28 Tobias Klauser <tklauser@distanz.ch> * sysdeps/unix/sysv/linux/dl-vdso.h (PREPARE_VERSION): Remove macro. diff --git a/sysdeps/unix/sysv/linux/tst-getdents64.c b/sysdeps/unix/sysv/linux/tst-getdents64.c index 24e77e0..8a28e6c 100644 --- a/sysdeps/unix/sysv/linux/tst-getdents64.c +++ b/sysdeps/unix/sysv/linux/tst-getdents64.c @@ -27,6 +27,7 @@ #include <support/check.h> #include <support/support.h> #include <support/xunistd.h> +#include <sys/mman.h> #include <unistd.h> /* Called by large_buffer_checks below. */ @@ -53,8 +54,13 @@ large_buffer_checks (int fd) size_t large_buffer_size; if (!__builtin_add_overflow (UINT_MAX, 2, &large_buffer_size)) { - char *large_buffer = malloc (large_buffer_size); - if (large_buffer == NULL) + int flags = MAP_ANONYMOUS | MAP_PRIVATE; +#ifdef MAP_NORESERVE + flags |= MAP_NORESERVE; +#endif + void *large_buffer = mmap (NULL, large_buffer_size, + PROT_READ | PROT_WRITE, flags, -1, 0); + if (large_buffer == MAP_FAILED) printf ("warning: could not allocate %zu bytes of memory," " subtests skipped\n", large_buffer_size); else @@ -65,8 +71,8 @@ large_buffer_checks (int fd) large_buffer_check (fd, large_buffer, UINT_MAX); large_buffer_check (fd, large_buffer, (size_t) UINT_MAX + 1); large_buffer_check (fd, large_buffer, (size_t) UINT_MAX + 2); + xmunmap (large_buffer, large_buffer_size); } - free (large_buffer); } }
reply other threads:[~2019-07-02 17:25 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190702172540.18372.qmail@sourceware.org \ --to=azanella@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).