076f82
commit 71326f1f2fd09dafb9c34404765fb88129e94237
076f82
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
076f82
Date:   Wed Apr 20 12:01:43 2022 -0300
076f82
076f82
    nptl: Fix pthread_cancel cancelhandling atomic operations
076f82
    
076f82
    The 404656009b reversion did not setup the atomic loop to set the
076f82
    cancel bits correctly.  The fix is essentially what pthread_cancel
076f82
    did prior 26cfbb7162ad.
076f82
    
076f82
    Checked on x86_64-linux-gnu and aarch64-linux-gnu.
076f82
    
076f82
    (cherry picked from commit 62be9681677e7ce820db721c126909979382d379)
076f82
076f82
diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c
076f82
index 2680b55586e035fe..64fd183fde59907b 100644
076f82
--- a/nptl/pthread_cancel.c
076f82
+++ b/nptl/pthread_cancel.c
076f82
@@ -122,6 +122,7 @@ __pthread_cancel (pthread_t th)
076f82
   int newval;
076f82
   do
076f82
     {
076f82
+    again:
076f82
       newval = oldval | CANCELING_BITMASK | CANCELED_BITMASK;
076f82
       if (oldval == newval)
076f82
 	break;
076f82
@@ -135,7 +136,7 @@ __pthread_cancel (pthread_t th)
076f82
 	  int newval2 = oldval | CANCELING_BITMASK;
076f82
 	  if (!atomic_compare_exchange_weak_acquire (&pd->cancelhandling,
076f82
 						     &oldval, newval2))
076f82
-	    continue;
076f82
+	    goto again;
076f82
 
076f82
 	  if (pd == THREAD_SELF)
076f82
 	    /* This is not merely an optimization: An application may