This is the mail archive of the libc-hacker@sourceware.org mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Add write barrier into pthread_cancel_init


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]