]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nptl: Fix pthread_cancel cancelhandling atomic operations
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 20 Apr 2022 15:01:43 +0000 (12:01 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 20 Apr 2022 15:22:34 +0000 (12:22 -0300)
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.

(cherry picked from commit 62be9681677e7ce820db721c126909979382d379)

nptl/pthread_cancel.c

index 2680b55586e035fefa55ccacbf8deaa1f5bf5ff6..64fd183fde59907b8c43be990ddec924028c4c0a 100644 (file)
@@ -122,6 +122,7 @@ __pthread_cancel (pthread_t th)
   int newval;
   do
     {
+    again:
       newval = oldval | CANCELING_BITMASK | CANCELED_BITMASK;
       if (oldval == newval)
        break;
@@ -135,7 +136,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