From patchwork Fri May 23 15:07:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Yixuan X-Patchwork-Id: 1097 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx23.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 41A0C360073 for ; Fri, 23 May 2014 08:08:00 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14307373) id F32E864049C28; Fri, 23 May 2014 08:07:59 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx23.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx23.g.dreamhost.com (Postfix) with ESMTPS id BC1C764049C1E for ; Fri, 23 May 2014 08:07:59 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=GFuR3yxTrsFMNXWL76Y9UzJO6cE0th+ +9a/8AtuM7gGf1P0R4riaq8T82LYZxavkI7yUm++dNO72R/wu+ai6GFKLXanYRWY 1d2C217LA0emPhv6XZtdCASqq6wPtdVYcMa8kmh+eTvga424Hhbl3rMjrYDPlDHn mF+05Jgeukkc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=FEzy1Dvw+BKjf0YuPA5lDC00a/Y=; b=H8E2O 1U5lfl53lHBpkT6WIMSkSxz/ZWqIdqpthLg0QvM0ofyCKVyP+2W36UDHui1LEEws xnE+aKIsoG3L0MctnLdtEqVDcADvdUXYcgkovRFF9Z5cDkr7xsIkFeCBjXluzWoP 3CJHCTTgcWvhBtz+7ob/SjQOckramHdfwJCsjo= Received: (qmail 4204 invoked by alias); 23 May 2014 15:07:46 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 4096 invoked by uid 89); 23 May 2014 15:07:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qc0-f169.google.com X-Received: by 10.229.112.5 with SMTP id u5mr7664465qcp.3.1400857662880; Fri, 23 May 2014 08:07:42 -0700 (PDT) From: Guo Yixuan To: libc-alpha@sourceware.org Cc: GUO Yixuan Subject: [PATCH 1/2] Fixed pthread_spin_lock on sparc32/64 (bug 16882) Date: Fri, 23 May 2014 11:07:10 -0400 Message-Id: <1400857631-15954-2-git-send-email-culu.gyx@gmail.com> In-Reply-To: <1400857631-15954-1-git-send-email-culu.gyx@gmail.com> References: <1400857631-15954-1-git-send-email-culu.gyx@gmail.com> X-DH-Original-To: glibc@patchwork.siddhesh.in From: GUO Yixuan The bug occurs under this situation. 1. thread1 gets the lock, set the byte to FF 2. when thread2 is trying to lock, it enters the loop, checking whether the byte is 00 3. thread1 unlocks, set to 00 4. thread2 finally gets the lock, without setting to FF 5. thread3 gets the lock, before thread2 unlocks it --- nptl/sysdeps/sparc/sparc32/pthread_spin_lock.S | 4 ++-- nptl/sysdeps/sparc/sparc64/pthread_spin_lock.S | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nptl/sysdeps/sparc/sparc32/pthread_spin_lock.S b/nptl/sysdeps/sparc/sparc32/pthread_spin_lock.S index ea863d7..3accc69 100644 --- a/nptl/sysdeps/sparc/sparc32/pthread_spin_lock.S +++ b/nptl/sysdeps/sparc/sparc32/pthread_spin_lock.S @@ -19,11 +19,11 @@ .text ENTRY(pthread_spin_lock) - ldstub [%o0], %g1 +1: ldstub [%o0], %g1 orcc %g1, 0x0, %g0 bne,a 2f ldub [%o0], %g1 -1: retl + retl mov 0, %o0 2: orcc %g1, 0x0, %g0 bne,a 2b diff --git a/nptl/sysdeps/sparc/sparc64/pthread_spin_lock.S b/nptl/sysdeps/sparc/sparc64/pthread_spin_lock.S index 0f849b2..aec6654 100644 --- a/nptl/sysdeps/sparc/sparc64/pthread_spin_lock.S +++ b/nptl/sysdeps/sparc/sparc64/pthread_spin_lock.S @@ -19,10 +19,10 @@ .text ENTRY(pthread_spin_lock) - ldstub [%o0], %g1 +1: ldstub [%o0], %g1 brnz,pn %g1, 2f membar #StoreLoad | #StoreStore -1: retl + retl mov 0, %o0 2: ldub [%o0], %g1 brnz,pt %g1, 2b