mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
nptl: Fix extraneous testing run by tst-rseq-nptl in the test driver
Fix an issue with commit 8f4632deb3
("Linux: rseq registration tests")
and prevent testing from being run in the process of the test driver
itself rather than just the test child where one has been forked. The
problem here is the unguarded use of a destructor to call a part of the
testing. The destructor function, 'do_rseq_destructor_test' is called
implicitly at program completion, however because it is associated with
the executable itself rather than an individual process, it is called
both in the test child *and* in the test driver itself.
Prevent this from happening by providing a guard variable that only
enables test invocation from 'do_rseq_destructor_test' in the process
that has first run 'do_test'. Consequently extra testing is invoked
from 'do_rseq_destructor_test' only once and in the correct process,
regardless of the use or the lack of of the '--direct' option. Where
called in the controlling test driver process that has neved called
'do_test' the destructor function silently returns right away without
taking any further actions, letting the test driver fail gracefully
where applicable.
This arrangement prevents 'tst-rseq-nptl' from ever causing testing to
hang forever and never complete, such as currently happening with the
'mips-linux-gnu' (o32 ABI) target.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
parent
b22923abb0
commit
9fb237a1c8
@ -28,6 +28,11 @@
|
||||
#include <sys/rseq.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Set this in 'do_test' only so as to invoke the destructor test in
|
||||
the test process only and not 'support_test_main' parent. Otherwise
|
||||
the test harness may hang in the destructor if something goes wrong. */
|
||||
static int run_destructor_test;
|
||||
|
||||
#ifdef RSEQ_SIG
|
||||
# include <array_length.h>
|
||||
# include <errno.h>
|
||||
@ -236,6 +241,9 @@ do_rseq_test (void)
|
||||
static void __attribute__ ((destructor))
|
||||
do_rseq_destructor_test (void)
|
||||
{
|
||||
if (!run_destructor_test)
|
||||
return;
|
||||
|
||||
/* Cannot use deferred failure reporting after main returns. */
|
||||
if (do_rseq_test ())
|
||||
FAIL_EXIT1 ("rseq not registered within destructor");
|
||||
@ -254,6 +262,7 @@ do_rseq_test (void)
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
run_destructor_test = 1;
|
||||
return do_rseq_test ();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user