[PATCH] nptl: Fix __libc_cleanup_pop_restore asynchronous restore (BZ#29214)
Andreas Schwab
schwab@suse.de
Tue Jun 7 10:27:26 GMT 2022
On Mai 31 2022, Adhemerval Zanella via Libc-alpha wrote:
> diff --git a/sysdeps/pthread/tst-cancel30.c b/sysdeps/pthread/tst-cancel30.c
> new file mode 100644
> index 0000000000..ef3f187e71
> --- /dev/null
> +++ b/sysdeps/pthread/tst-cancel30.c
> @@ -0,0 +1,75 @@
> +/* Check if printf like functions does not disable asynchronous cancellation
> + mode (BZ#29214).
> +
> + Copyright (C) 2022 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <support/check.h>
> +#include <support/xthread.h>
> +#include <support/xstdio.h>
> +
> +static pthread_barrier_t b;
> +
> +static void *
> +tf (void *arg)
> +{
> + int old;
> +
> + TEST_COMPARE (pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL), 0);
> +
> + TEST_COMPARE (pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old), 0);
> + TEST_COMPARE (old, PTHREAD_CANCEL_ASYNCHRONOUS);
> +
> + /* Check if internal lock cleanup routines restore the cancellation type
> + correctly. */
> + printf ("...\n");
> + TEST_COMPARE (pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old), 0);
> + TEST_COMPARE (old, PTHREAD_CANCEL_ASYNCHRONOUS);
> +
> + xpthread_barrier_wait (&b);
> +
> + /* Wait indefinitely for cancellation, which only works if asynchronous
> + cancellation is enabled. */
> +#ifdef SYS_futex
> + syscall (SYS_futex, &(int){0}, FUTEX_WAIT_PRIVATE, 0, NULL, NULL, 0);
> +#else
> + for (;;);
> +#endif
Should that handle SYS_futex_time64?
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
More information about the Libc-alpha
mailing list