mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Jaydeep Patil <Jaydeep.Patil@imgtec.com>
To: "nsz@port70.net" <nsz@port70.net>
Cc: "musl@lists.openwall.com" <musl@lists.openwall.com>,
	"dalias@libc.org" <dalias@libc.org>
Subject: [PATCH] malloc-brk-fail test
Date: Thu, 10 Mar 2016 10:36:54 +0000	[thread overview]
Message-ID: <BD7773622145634B952E5B54ACA8E349AA2466D7@PUMAIL01.pu.imgtec.org> (raw)

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

Hi Szabolcs,

Page size on the MIPS64 Linux (v4.4) system we are using to test MUSL is 64kb. The t_vmfill leaves up to 64kb memory, thus malloc of size 10000 (less than page size) after t_vmfill in this case succeeds.

Could you please consider this patch?

diff --git a/src/regression/malloc-brk-fail.c b/src/regression/malloc-brk-fail.c
index d0ccd35..a1c2f32 100644
--- a/src/regression/malloc-brk-fail.c
+++ b/src/regression/malloc-brk-fail.c
@@ -9,6 +9,10 @@

#define T(f) ((f)==0 || (t_error(#f " failed: %s\n", strerror(errno)), 0))

+#ifndef PAGE_SIZE
+       #define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
+#endif
+
int main(void)
{
        void *p;
@@ -26,9 +30,9 @@ int main(void)

        // malloc should fail here
        errno = 0;
-       q = malloc(10000);
+       q = malloc(PAGE_SIZE);
        if (q)
-               t_error("malloc(10000) succeeded after memory is filled\n");
+               t_error("malloc(PAGE_SIZE) succeeded after memory is filled\n");
        else if (errno != ENOMEM)
                t_error("malloc did not fail with ENOMEM, got %s\n", strerror(errno));

@@ -36,9 +40,9 @@ int main(void)
        T(munmap((char*)p+65536, 65536));

        // malloc should succeed now
-       q = malloc(10000);
+       q = malloc(PAGE_SIZE);
        if (!q)
-               t_error("malloc(10000) failed (eventhough 64k is available to mmap): %s\n", strerror(errno));
+               t_error("malloc(PAGE_SIZE) failed (eventhough 64k is available to mmap): %s\n", strerror(errno));

        return t_status;
}

Thanks,
Jaydeep


[-- Attachment #2: Type: text/html, Size: 6043 bytes --]

                 reply	other threads:[~2016-03-10 10:36 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=BD7773622145634B952E5B54ACA8E349AA2466D7@PUMAIL01.pu.imgtec.org \
    --to=jaydeep.patil@imgtec.com \
    --cc=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --cc=nsz@port70.net \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).