From patchwork Thu Jun 23 19:26:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiyoung Yun X-Patchwork-Id: 13340 Received: (qmail 99486 invoked by alias); 23 Jun 2016 19:26:31 -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 99468 invoked by uid 89); 23 Jun 2016 19:26:30 -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 spammy=2016-06-24, 20160624, timespec X-HELO: mail-pf0-f193.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Eo/uO78n8TFAID/rIG8wHkWLMoYF/CvjjxME1+dgjFw=; b=iheB1h6HbpnJnxah5FKCKYo3geH+bxkJh6TltcCpQHiclOY7QD76Y/BX+pLxeOoWnZ HnC/by+5rkhGmo2c/mANJ+VEhOrU0JqEe/CougDhv/0HX6Fm8EoGv5hIfhVQ5qYZareq m/A9jNcwkS6ZiYRiDaR07r5+ygBx5E6BPaB2Kodtk8lEttSYiy+Nrjg9EIPQldNYVwXD nE9CKiOYzkugsRoEbmFvmPBcXVm9U8GOrkjosf9EByZAsy5Dkt/ZAUBQRq58Bs5hsZOu FevwFOXbjtWLMoxV+4tzO9sBMUAeb28PfM2K6SedYwtR+dQx7FZ3H+Durkz5rfE93D7o ZNww== X-Gm-Message-State: ALyK8tInJmy0IC8vcq6JOKzsO5KRHPE/ipyzkiIoJ3HHV3B+FJdlis9x3U+ZLuycjfDlYg== X-Received: by 10.98.76.211 with SMTP id e80mr123308pfj.28.1466709987336; Thu, 23 Jun 2016 12:26:27 -0700 (PDT) From: Jiyoung Yun To: libc-alpha@sourceware.org Cc: jy910.yun@samsung.com, Jiyoung Yun Subject: [PATCH] Fix robust mutex daedlock [BZ #20263] Date: Fri, 24 Jun 2016 04:26:22 +0900 Message-Id: <1466709982-5689-1-git-send-email-t2wish@gmail.com> In Linux/ARM environment, a robust mutex can't catch the timeout result when it is already owned by other thread and requests to try lock with a specific time value(pthread_mutex_timedlock). The futex already returns the ETIMEDOUT result but there is no check the return value and it makes a deadlock. * nptl/lowlevelrobustlock.c: Implement ETIMEDOUT logic. Signed-off-by: Jiyoung Yun --- ChangeLog | 5 +++++ nptl/lowlevelrobustlock.c | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4bfee94..7b95767 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-06-24 Jiyoung Yun + + [BZ #20263] + * nptl/lowlevelrobustlock.c: Implement ETIMEDOUT logic. + 2016-06-23 Florian Weimer * test-skeleton.c (xrealloc): Support deallocation with n == 0. diff --git a/nptl/lowlevelrobustlock.c b/nptl/lowlevelrobustlock.c index 3b988b2..8842032 100644 --- a/nptl/lowlevelrobustlock.c +++ b/nptl/lowlevelrobustlock.c @@ -113,15 +113,20 @@ __lll_robust_timedlock_wait (int *futex, const struct timespec *abstime, && atomic_compare_and_exchange_bool_acq (futex, newval, oldval)) continue; + int err; /* If *futex == 2, wait until woken or timeout. */ #if (!defined __ASSUME_FUTEX_CLOCK_REALTIME \ || !defined lll_futex_timed_wait_bitset) - lll_futex_timed_wait (futex, newval, &rt, private); + err = lll_futex_timed_wait (futex, newval, &rt, private); #else - lll_futex_timed_wait_bitset (futex, newval, abstime, + err = lll_futex_timed_wait_bitset (futex, newval, abstime, FUTEX_CLOCK_REALTIME, private); #endif + /* the futex call time out */ + if (err == -ETIMEDOUT) + return ETIMEDOUT; + try: ; }