mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] malloc-brk-fail test
@ 2016-03-10 10:36 Jaydeep Patil
  0 siblings, 0 replies; only message in thread
From: Jaydeep Patil @ 2016-03-10 10:36 UTC (permalink / raw)
  To: nsz; +Cc: musl, dalias

[-- 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 --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-03-10 10:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-10 10:36 [PATCH] malloc-brk-fail test Jaydeep Patil

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