From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2435 invoked by alias); 4 May 2004 19:11:51 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 2401 invoked from network); 4 May 2004 19:11:51 -0000 Received: from unknown (HELO sunsite.ms.mff.cuni.cz) (195.113.15.26) by sources.redhat.com with SMTP; 4 May 2004 19:11:51 -0000 Received: from sunsite.ms.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8) with ESMTP id i44GxX3j000775; Tue, 4 May 2004 18:59:33 +0200 Received: (from jakub@localhost) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8/Submit) id i44GxXFo000773; Tue, 4 May 2004 18:59:33 +0200 Date: Tue, 04 May 2004 19:11:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] Fix [BZ #110] Message-ID: <20040504165932.GN5191@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i X-SW-Source: 2004-05/txt/msg00013.txt.bz2 Hi! This patch adjusts tst-stack1, so that it doesn't rely on user defined stack being reusable/freeable after successful pthread_join and adjusts comment in tst-stack3. 2004-05-04 Jakub Jelinek nptl/ * tst-stack3.c: Note testing functionality beyond POSIX. linuxthreads/ * tst-stack1.c: Don't include mcheck.h. (do_test): Make sure user defined stacks aren't reused, don't free them at the end. [BZ #110] --- libc/nptl/tst-stack3.c.jj 2003-12-18 00:51:51.000000000 +0100 +++ libc/nptl/tst-stack3.c 2004-05-04 20:25:20.517536229 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2003. @@ -18,7 +18,10 @@ 02111-1307 USA. */ /* Test whether pthread_create/pthread_join with user defined stacks - doesn't leak memory. */ + doesn't leak memory. + NOTE: this tests functionality beyond POSIX. In POSIX user defined + stacks cannot be ever freed once used by pthread_create nor they can + be reused for other thread. */ #include #include --- libc/linuxthreads/tst-stack1.c.jj 2003-12-18 00:48:08.000000000 +0100 +++ libc/linuxthreads/tst-stack1.c 2004-05-04 21:07:28.807433761 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2003. @@ -17,11 +17,9 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -/* Test whether pthread_create/pthread_join with user defined stacks - doesn't leak memory. */ +/* Test pthread_create/pthread_join with user defined stacks. */ #include -#include #include #include #include @@ -40,10 +38,8 @@ tf (void *p) static int do_test (void) { - mtrace (); - void *stack; - int res = posix_memalign (&stack, getpagesize (), 4 * PTHREAD_STACK_MIN); + int res = posix_memalign (&stack, getpagesize (), 16 * 4 * PTHREAD_STACK_MIN); if (res) { printf ("malloc failed %s\n", strerror (res)); @@ -54,15 +50,17 @@ do_test (void) pthread_attr_init (&attr); int result = 0; - res = pthread_attr_setstack (&attr, stack, 4 * PTHREAD_STACK_MIN); - if (res) - { - printf ("pthread_attr_setstack failed %d\n", res); - result = 1; - } - for (int i = 0; i < 16; ++i) { + res = pthread_attr_setstack (&attr, stack + 4 * i * PTHREAD_STACK_MIN, + 4 * PTHREAD_STACK_MIN); + if (res) + { + printf ("pthread_attr_setstack failed %d\n", res); + result = 1; + continue; + } + /* Create the thread. */ pthread_t th; res = pthread_create (&th, &attr, tf, NULL); @@ -90,7 +88,6 @@ do_test (void) result = 1; } - free (stack); return result; } Jakub