From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 24BC33857C4A; Wed, 20 Apr 2022 15:06:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 24BC33857C4A Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc] nptl: Fix pthread_cancel cancelhandling atomic operations X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/master X-Git-Oldrev: c72a1a062a1ded52719802c07ab459e1fd54d2a6 X-Git-Newrev: 62be9681677e7ce820db721c126909979382d379 Message-Id: <20220420150648.24BC33857C4A@sourceware.org> Date: Wed, 20 Apr 2022 15:06:48 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Apr 2022 15:06:48 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=62be9681677e7ce820db721c126909979382d379 commit 62be9681677e7ce820db721c126909979382d379 Author: Adhemerval Zanella Date: Wed Apr 20 12:01:43 2022 -0300 nptl: Fix pthread_cancel cancelhandling atomic operations The 404656009b reversion did not setup the atomic loop to set the cancel bits correctly. The fix is essentially what pthread_cancel did prior 26cfbb7162ad. Checked on x86_64-linux-gnu and aarch64-linux-gnu. Diff: --- nptl/pthread_cancel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c index c76882e279..e67b2df5cc 100644 --- a/nptl/pthread_cancel.c +++ b/nptl/pthread_cancel.c @@ -121,6 +121,7 @@ __pthread_cancel (pthread_t th) int newval; do { + again: newval = oldval | CANCELING_BITMASK | CANCELED_BITMASK; if (oldval == newval) break; @@ -134,7 +135,7 @@ __pthread_cancel (pthread_t th) int newval2 = oldval | CANCELING_BITMASK; if (!atomic_compare_exchange_weak_acquire (&pd->cancelhandling, &oldval, newval2)) - continue; + goto again; if (pd == THREAD_SELF) /* This is not merely an optimization: An application may