public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix tst-rwlock14
@ 2004-08-11 13:32 Jakub Jelinek
  2004-08-11 18:49 ` Roland McGrath
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2004-08-11 13:32 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers

Hi!

*(pthread_t *) arg points to a variable (me) on initial thread's stack.
If tf returns from pthread_barrier_wait after do_test returns from
pthread_barrier_wait and runs all the code until return from routine,
*mtp in tf reads garbage.
The patch below ensures that the handle is read from initial thread's
stack before pthread_barrier_wait, so the routine certainly did not return
yet.
Alternatively me variable in do_test would need to be static, or
it would need to pass pthread_t, not pthread_t *.

2004-08-11  Jakub Jelinek  <jakub@redhat.com>

	* tst-rwlock14.c (tf): Read main thread handle from *arg
	before pthread_barrier_wait.

--- libc/nptl/tst-rwlock14.c.jj	2004-08-11 15:20:06.504152481 +0200
+++ libc/nptl/tst-rwlock14.c	2004-08-11 15:26:34.056471560 +0200
@@ -38,12 +38,12 @@ tf (void *arg)
       exit (EXIT_FAILURE);
     }
 
-  pthread_barrier_wait (&b);
+  pthread_t mt = *(pthread_t *) arg;
 
-  pthread_t *mtp = (pthread_t *) arg;
+  pthread_barrier_wait (&b);
 
   /* This call will never return.  */
-  pthread_join (*mtp, NULL);
+  pthread_join (mt, NULL);
 
   return NULL;
 }

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix tst-rwlock14
  2004-08-11 13:32 [PATCH] Fix tst-rwlock14 Jakub Jelinek
@ 2004-08-11 18:49 ` Roland McGrath
  0 siblings, 0 replies; 2+ messages in thread
From: Roland McGrath @ 2004-08-11 18:49 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Ulrich Drepper, Glibc hackers

> 2004-08-11  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* tst-rwlock14.c (tf): Read main thread handle from *arg
> 	before pthread_barrier_wait.

Applied.


Thanks,
Roland

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-08-11 18:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-11 13:32 [PATCH] Fix tst-rwlock14 Jakub Jelinek
2004-08-11 18:49 ` Roland McGrath

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