The 40465600 reversion did not setup the atomic loop to set the cancel bits correctly. The fix is essentially what pthread_cancel did prior 26cfbb71. Checked on x86_64-linux-gnu and aarch64-linux-gnu.
mentioned in commit 71326f1f
mentioned in commit 68d3a9a6