From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1FD6A386F41D; Wed, 28 Oct 2020 13:54:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1FD6A386F41D From: "yeatesrichardr at johndeere dot com" To: glibc-bugs@sourceware.org Subject: [Bug nptl/26801] New: pthread_mutex_clocklock with CLOCK_MONOTONIC can fail on PI futexs Date: Wed, 28 Oct 2020 13:54:30 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: nptl X-Bugzilla-Version: 2.30 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: yeatesrichardr at johndeere dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2020 13:54:31 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D26801 Bug ID: 26801 Summary: pthread_mutex_clocklock with CLOCK_MONOTONIC can fail on PI futexs Product: glibc Version: 2.30 Status: UNCONFIRMED Severity: normal Priority: P2 Component: nptl Assignee: unassigned at sourceware dot org Reporter: yeatesrichardr at johndeere dot com CC: drepper.fsp at gmail dot com Target Milestone: --- Created attachment 12925 --> https://sourceware.org/bugzilla/attachment.cgi?id=3D12925&action=3Ded= it Test program showing early return from pthread_mutex_clocklock() When a pthread mutex is ROBUST_NP, ERRORCHECK, and PRIO_INHERIT (other combination may fall into this same category) and pthread_mutex_clocklock()= is used with CLOCK_MONOTONIC, the call will return immediately with ETIMEDOUT = if the mutex is already taken at the time of the call. This was tested with glibc 2.30, but still appears to be present in the lat= est source code. The root cause is at line 381 of pthread_mutex_timedlock.c: int e =3D futex_lock_pi64 (&mutex->__data.__lock, abstime, private); Here, the CLOCK_MONOTONIC abstime is being passed to futex_lock_pi64 which requires a CLOCK_REALTIME abstime. Of course, a CLOCK_MONOTONIC looks a lot "earlier" than a CLOCK_REALTIME, so it times out immediately. It's not sufficient to convert from CLOCK_MONOTONIC to CLOCK_REALTIME since that would violate the assumption one is using, that changes to the wall cl= ock time won't interfere with CLOCK_MONOTONIC timed waits. This was tested with kernel 5.4.47. Example program is attached. --=20 You are receiving this mail because: You are on the CC list for the bug.=