From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3468 invoked by alias); 16 Nov 2005 23:19:01 -0000 Received: (qmail 3436 invoked by uid 22791); 16 Nov 2005 23:19:01 -0000 Received: from sunsite.ms.mff.cuni.cz (HELO sunsite.mff.cuni.cz) (195.113.15.26) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 16 Nov 2005 23:19:01 +0000 Received: from sunsite.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by sunsite.mff.cuni.cz (8.13.1/8.13.1) with ESMTP id jAGNIipY011113; Thu, 17 Nov 2005 00:18:44 +0100 Received: (from jakub@localhost) by sunsite.mff.cuni.cz (8.13.1/8.13.1/Submit) id jAGNIiqn011112; Thu, 17 Nov 2005 00:18:44 +0100 Date: Wed, 16 Nov 2005 23:19:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] Add write barrier into pthread_cancel_init Message-ID: <20051116231843.GL16723@sunsite.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.4.1i Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2005-11/txt/msg00010.txt.bz2 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 * 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 . @@ -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