public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Fix 2 NPTL testcases
Date: Mon, 18 Sep 2006 10:48:00 -0000	[thread overview]
Message-ID: <20060918104847.GN4556@sunsite.mff.cuni.cz> (raw)

Hi!

tst-kill4 does something apps generally shouldn't do - it relies on the
thread descriptor to be put into stack cache and not being immediately
freed, unfortunately if the stack size is larger than the limit for
stack cache, it is freed immediately and the stack size is determined
from current ulimit -s.  This test kept crashing on ia64 for a while,
but can be reproduced e.g. on ppc32 with ulimit -s 80000.

On IA-64 with its larger page size, writing 100000 bytes into a pipe
succeeds in contemporary kernels, even when nobody reads anything
from the other pipe's end.  This patch changes it to loop, so it will
eventually block.

2006-09-18  Jakub Jelinek  <jakub@redhat.com>

	* tst-kill4.c (do_test): Explicitly set tf thread's stack size.
	* tst-cancel2.c (tf): Loop as long as something was written.

--- libc/nptl/tst-kill4.c.jj	2003-02-21 21:27:54.000000000 +0100
+++ libc/nptl/tst-kill4.c	2006-09-18 12:32:48.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
 
@@ -35,13 +35,30 @@ tf (void *a)
 int
 do_test (void)
 {
+  pthread_attr_t at;
+  if (pthread_attr_init (&at) != 0)
+    {
+      puts ("attr_create failed");
+      exit (1);
+    }
+
+  /* Limit thread stack size, because if it is too large, pthread_join
+     will free it immediately rather than put it into stack cache.  */
+  if (pthread_attr_setstacksize (&at, 2 * 1024 * 1024) != 0)
+    {
+      puts ("setstacksize failed");
+      exit (1);
+    }
+
   pthread_t th;
-  if (pthread_create (&th, NULL, tf, NULL) != 0)
+  if (pthread_create (&th, &at, tf, NULL) != 0)
     {
       puts ("create failed");
       exit (1);
     }
 
+  pthread_attr_destroy (&at);
+
   if (pthread_join (th, NULL) != 0)
     {
       puts ("join failed");
--- libc/nptl/tst-cancel2.c.jj	2002-11-26 23:49:53.000000000 +0100
+++ libc/nptl/tst-cancel2.c	2006-09-18 12:33:53.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -33,11 +33,7 @@ tf (void *arg)
      write blocks.  */
   char buf[100000];
 
-  if (write (fd[1], buf, sizeof (buf)) == sizeof (buf))
-    {
-      puts ("write succeeded");
-      return (void *) 1l;
-    }
+  while (write (fd[1], buf, sizeof (buf)) > 0);
 
   return (void *) 42l;
 }

	Jakub

             reply	other threads:[~2006-09-18 10:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-18 10:48 Jakub Jelinek [this message]
2006-09-18 13:42 ` Ulrich Drepper

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=20060918104847.GN4556@sunsite.mff.cuni.cz \
    --to=jakub@redhat.com \
    --cc=drepper@redhat.com \
    --cc=libc-hacker@sources.redhat.com \
    /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).