public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Add write barrier into pthread_cancel_init
@ 2005-11-16 23:19 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2005-11-16 23:19 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers

Hi!

If the compiler and/or processor reorders the writes to libgcc_s_*
variables in pthread_cancel_init, pthread_cancel_init might return early
if libgcc_s_getcfa has been already written, but some other libgcc_s_*
pointer the caller is actually interested in has not been written yet.

2005-11-17  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/pthread/unwind-forcedunwind.c (pthread_cancel_init): Put
	a write barrier before writing libgcc_s_getcfa.

--- libc/nptl/sysdeps/pthread/unwind-forcedunwind.c.jj	2003-09-04 07:41:57.000000000 +0200
+++ libc/nptl/sysdeps/pthread/unwind-forcedunwind.c	2005-11-17 00:13:37.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jakub Jelinek <jakub@redhat.com>.
 
@@ -56,6 +56,10 @@ pthread_cancel_init (void)
   libgcc_s_resume = resume;
   libgcc_s_personality = personality;
   libgcc_s_forcedunwind = forcedunwind;
+  /* Make sure libgcc_s_getcfa is written last.  Otherwise,
+     pthread_cancel_init might return early even when the pointer the
+     caller is interested in is not initialized yet.  */
+  atomic_write_barrier ();
   libgcc_s_getcfa = getcfa;
 }
 

	Jakub

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-11-16 23:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-16 23:19 [PATCH] Add write barrier into pthread_cancel_init Jakub Jelinek

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