mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-08 17:42:12 +03:00
nptl: Fix testcases for new pthread cancellation mechanism
With upcoming fix for BZ#12683, pthread cancellation does not act for: 1. If syscall is blocked but with some side effects already having taken place (e.g. a partial read or write). 2. After the syscall has returned. The main change is due the fact programs need to act in syscalls with side-effects (for instance, to avoid leak of allocated resources or handle partial read/write). This patch changes the NPTL testcase that assumes the old behavior and also changes the tst-backtrace{5,6} to ignore the cancellable wrappers. Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, aarch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, powerpc-linux-gnu, sparcv9-linux-gnu, and sparc64-linux-gnu. * debug/tst-backtrace5.c (handle_signal): Avoid cancellable wrappers in backtrace analysis. * nptl/tst-cancel4.c (tf_write): Handle cancelled syscall with side-effects. (tf_send): Likewise.
This commit is contained in:
committed by
Adhemerval Zanella
parent
17cc27d5b7
commit
d0d7f85f66
@@ -1,5 +1,11 @@
|
|||||||
2019-01-03 Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
2019-01-03 Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
|
||||||
|
* debug/tst-backtrace5.c (handle_signal): Avoid cancellable wrappers
|
||||||
|
in backtrace analysis.
|
||||||
|
* nptl/tst-cancel4.c (tf_write): Handle cancelled syscall with
|
||||||
|
side-effects.
|
||||||
|
(tf_send): Likewise.
|
||||||
|
|
||||||
* io/creat.c (LIBC_CANCEL_HANDLED): Remove macro.
|
* io/creat.c (LIBC_CANCEL_HANDLED): Remove macro.
|
||||||
* io/ppoll.c (LIBC_CANCEL_HANDLED): Likewise.
|
* io/ppoll.c (LIBC_CANCEL_HANDLED): Likewise.
|
||||||
* misc/pselect.c (LIBC_CANCEL_HANDLED): Likewise.
|
* misc/pselect.c (LIBC_CANCEL_HANDLED): Likewise.
|
||||||
|
@@ -69,17 +69,18 @@ handle_signal (int signum)
|
|||||||
FAIL ();
|
FAIL ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Do not check name for signal trampoline. */
|
|
||||||
i = 2;
|
/* Do not check name for signal trampoline or cancellable syscall
|
||||||
if (!match (symbols[i++], "read"))
|
wrappers (__syscall_cancel*). */
|
||||||
|
for (; i < n - 1; i++)
|
||||||
|
if (match (symbols[i], "read"))
|
||||||
|
break;
|
||||||
|
if (i == n - 1)
|
||||||
{
|
{
|
||||||
/* Perhaps symbols[2] is __kernel_vsyscall? */
|
FAIL ();
|
||||||
if (!match (symbols[i++], "read"))
|
return;
|
||||||
{
|
|
||||||
FAIL ();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; i < n - 1; i++)
|
for (; i < n - 1; i++)
|
||||||
if (!match (symbols[i], "fn"))
|
if (!match (symbols[i], "fn"))
|
||||||
{
|
{
|
||||||
|
@@ -166,6 +166,10 @@ tf_write (void *arg)
|
|||||||
char buf[WRITE_BUFFER_SIZE];
|
char buf[WRITE_BUFFER_SIZE];
|
||||||
memset (buf, '\0', sizeof (buf));
|
memset (buf, '\0', sizeof (buf));
|
||||||
s = write (fd, buf, sizeof (buf));
|
s = write (fd, buf, sizeof (buf));
|
||||||
|
/* The write can return a value higher than 0 (meaning partial write)
|
||||||
|
due to the SIGCANCEL, but the thread may still be pending
|
||||||
|
cancellation. */
|
||||||
|
pthread_testcancel ();
|
||||||
|
|
||||||
pthread_cleanup_pop (0);
|
pthread_cleanup_pop (0);
|
||||||
|
|
||||||
@@ -743,6 +747,10 @@ tf_send (void *arg)
|
|||||||
char mem[WRITE_BUFFER_SIZE];
|
char mem[WRITE_BUFFER_SIZE];
|
||||||
|
|
||||||
send (tempfd2, mem, arg == NULL ? sizeof (mem) : 1, 0);
|
send (tempfd2, mem, arg == NULL ? sizeof (mem) : 1, 0);
|
||||||
|
/* The send can return a value higher than 0 (meaning partial send)
|
||||||
|
due to the SIGCANCEL, but the thread may still be pending
|
||||||
|
cancellation. */
|
||||||
|
pthread_testcancel ();
|
||||||
|
|
||||||
pthread_cleanup_pop (0);
|
pthread_cleanup_pop (0);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user