public inbox for libc-stable@sourceware.org
 help / color / mirror / Atom feed
From: fweimer@redhat.com (Florian Weimer)
To: libc-stable@sourceware.org
Subject: [2.28 COMMITTED] Test stdlib/test-bz22786 exits now with unsupported if malloc fails.
Date: Mon, 01 Jan 2018 00:00:00 -0000	[thread overview]
Message-ID: <20181102095052.1F0124399457D@oldenburg.str.redhat.com> (raw)

From: Stefan Liebler <stli@linux.ibm.com>

The test tries to allocate more than 2^31 bytes which will always fail on s390
as it has maximum 2^31bit of memory.
Before commit 6c3a8a9d868a8deddf0d6dcc785b6d120de90523, this test returned
unsupported if malloc fails.  This patch re enables this behaviour.

Furthermore support_delete_temp_files() failed to remove the temp directory
in this case as it is not empty due to the created symlink.
Thus the creation of the symlink is moved behind malloc.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

ChangeLog:

	* stdlib/test-bz22786.c (do_test): Return EXIT_UNSUPPORTED
	if malloc fails.

(cherry picked from commit 3bad2358d67d371497079bba4f8eca9c0096f4e2)

2018-08-30  Stefan Liebler  <stli@linux.ibm.com>

	* stdlib/test-bz22786.c (do_test): Return EXIT_UNSUPPORTED
	if malloc fails.

diff --git a/stdlib/test-bz22786.c b/stdlib/test-bz22786.c
index d1aa69106c..777bf9180f 100644
--- a/stdlib/test-bz22786.c
+++ b/stdlib/test-bz22786.c
@@ -39,16 +39,25 @@ do_test (void)
   const char *lnk = xasprintf ("%s/symlink", dir);
   const size_t path_len = (size_t) INT_MAX + strlen (lnk) + 1;
 
-  TEST_VERIFY_EXIT (symlink (".", lnk) == 0);
-
   DIAG_PUSH_NEEDS_COMMENT;
 #if __GNUC_PREREQ (7, 0)
   /* GCC 7 warns about too-large allocations; here we need such
      allocation to succeed for the test to work.  */
   DIAG_IGNORE_NEEDS_COMMENT (7, "-Walloc-size-larger-than=");
 #endif
-  char *path = xmalloc (path_len);
+  char *path = malloc (path_len);
   DIAG_POP_NEEDS_COMMENT;
+  if (path == NULL)
+    {
+      printf ("malloc (%zu): %m\n", path_len);
+      /* On 31-bit s390 the malloc will always fail as we do not have
+	 so much memory, and we want to mark the test unsupported.
+	 Likewise on systems with little physical memory the test will
+	 fail and should be unsupported.  */
+      return EXIT_UNSUPPORTED;
+    }
+
+  TEST_VERIFY_EXIT (symlink (".", lnk) == 0);
 
   /* Construct very long path = "/tmp/bz22786.XXXX/symlink/aaaa....."  */
   char *p = mempcpy (path, lnk, strlen (lnk));

                 reply	other threads:[~2018-11-02  9:50 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=20181102095052.1F0124399457D@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-stable@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: link
Be 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).