* [PATCH] Fix [BZ #110]
@ 2004-05-04 19:11 Jakub Jelinek
2004-05-04 19:25 ` Ulrich Drepper
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2004-05-04 19:11 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: Glibc hackers
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 <jakub@redhat.com>
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 <jakub@redhat.com>, 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 <limits.h>
#include <mcheck.h>
--- 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 <jakub@redhat.com>, 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 <limits.h>
-#include <mcheck.h>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
@@ -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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix [BZ #110]
2004-05-04 19:11 [PATCH] Fix [BZ #110] Jakub Jelinek
@ 2004-05-04 19:25 ` Ulrich Drepper
0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2004-05-04 19:25 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Glibc hackers
I've applied the patch with some minor changes.
--
⧠Ulrich Drepper ⧠Red Hat, Inc. ⧠444 Castro St ⧠Mountain View, CA â
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-05-04 19:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-04 19:11 [PATCH] Fix [BZ #110] Jakub Jelinek
2004-05-04 19:25 ` Ulrich Drepper
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).