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: 351873 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 797F014009C for ; Sat, 24 May 2014 01:08:03 +1000 (EST) 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=WSsyXzdIkh94U7rCcL17AXcRPbJMR4v 7BQ7vuuVBLbkI2xGnK1G5EIptdpnlC6N5czxpse/rdoXPabomuyp0pTSJRHDyPfw 3o+ee5KdPx1LOZWs79ioZqj2tHAV2AKAZT5U+rXb4YY33uJQtm4kpPMdlYUrHlWW 72b9luZo6Q+8= 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=caICr 8WaqDOA12zJhaeXJVOY13gF36s6lFdVNW6Qya0eHSD5e/fYM0aZQdG0vgtxIXQbN yAsEkR2r4JfoTaQJ7pKKBdhc18g698TRMX22dDmdx2LRSBpZH/UoWK+Jsw7JIWq4 +rDv+8UDs0bSsIvU8ekJkC0DCHpN9ng0YMV2pc= 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> 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