[CRIU] zdtm test build failure on s390x (s390x_regs_check.c)
Michael Holzheu
holzheu at linux.vnet.ibm.com
Tue Sep 26 17:58:32 MSK 2017
Am Mon, 25 Sep 2017 14:50:38 +0200
schrieb Adrian Reber <adrian at lisas.de>:
> On Wed, Sep 06, 2017 at 06:33:10PM +0200, Michael Holzheu wrote:
> > On Wed, 6 Sep 2017 17:49:30 +0200
> > Adrian Reber <adrian at lisas.de> wrote:
> >
> > > On Tue, Sep 05, 2017 at 07:47:26PM +0200, Michael Holzheu wrote:
> > > > On Tue, 5 Sep 2017 17:56:08 +0200
> > > > Adrian Reber <adrian at lisas.de> wrote:
> > > >
> > > > > When running 'make zdtm' on s390x it fails on my RHEL kernel with:
> > > > >
> > > > > make[3]: Leaving directory `/tmp/criu/test/zdtm/lib'
> > > > > CC s390x_regs_check.o
> > > > > s390x_regs_check.c: In function ‘util_hexdump_grp’:
> > > > > s390x_regs_check.c:214:7: error: ‘ptr’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> > > > > ptr += sprintf(ptr, "%02x", buf[i]);
> > > > > ^
> > > >
> > > > Obviously the compiler does not understand the "if (first)" construct.
> > > >
> > > > I assume the following will fix the problem:
> > > > ---
> > > > [CRIU][PATCH] zdtm/s390x_regs_check: Fix compiler warning
> > > >
> > > > When running 'make zdtm' on s390x it fails on RHEL7 with:
> > > >
> > > > make[3]: Leaving directory `/tmp/criu/test/zdtm/lib'
> > > > CC s390x_regs_check.o
> > > > s390x_regs_check.c: In function "util_hexdump_grp":
> > > > s390x_regs_check.c:214:7: error: "ptr" may be used uninitialized
> > > > in this function [-Werror=maybe-uninitialized]
> > > > ptr += sprintf(ptr, "%02x", buf[i]);
> > > >
> > > > Fix this and assign ptr from the beginning to help gcc.
> > > >
> > > > Signed-off-by: Michael Holzheu <holzheu at linux.vnet.ibm.com>
> > > > ---
> > > > test/zdtm/static/s390x_regs_check.c | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/test/zdtm/static/s390x_regs_check.c b/test/zdtm/static/s390x_regs_check.c
> > > > index a92679a..1a7e841 100644
> > > > --- a/test/zdtm/static/s390x_regs_check.c
> > > > +++ b/test/zdtm/static/s390x_regs_check.c
> > > > @@ -198,8 +198,8 @@ struct reg_set *reg_set_vec[] = {
> > > > void util_hexdump_grp(const char *tag, const void *data, int grp,
> > > > int count, int indent)
> > > > {
> > > > + char str[1024], *ptr = str;
> > > > const char *buf = data;
> > > > - char str[1024], *ptr;
> > > > int i, first = 1;
> > > >
> > > > for (i = 0; i < count; i++) {
> > > > --
> > > > 2.7.4
> > >
> > > Thanks the patch works. Now it compiles without errors. But...
> > >
> > > The test seems to hang. criu never starts in zdtm.py to do the actual
> > > dump. In the output file I see:
> > >
> > > 11:48:08.040: 45159: ------------- START 1 PROCESS + 2 THREADS ---------------
> > > 11:48:08.080: 45159: STARTED: pid = 45160
> > > 11:48:08.149: 45159: STARTED: pid = 45162
> > > 11:48:08.149: 45159: STARTED: pid = 45161
> > > 11:48:08.149: 45159: ---------------------- SET REGISTERS --------------------
> > > 11:48:08.149: 45159: SET: pid = 45160
> > > 11:48:08.174: 45159: REGSET: PRFPREG -> DONE
> > > 11:48:08.174: 45159: REGSET: VXRS_LOW -> not supported by machine
> > > 11:48:08.174: 45159: REGSET: VXRS_HIGH -> not supported by machine
> > > 11:48:08.174: 45159: SET: pid = 45162
> >
> > Looks like it started all threads and somehow hangs when attaching to
> > the second thread with pid=45162 in ptrace_attach().
> >
> > >
> > > One of the three process uses 100% CPU and that is how the process tree looks like:
> >
> > After a thread is started it loops to ensure that it does not change
> > registers any more:
> >
> > static inline void send_tid_and_loop(int fd)
> > {
> > int tid = syscall(__NR_gettid);
> >
> > asm volatile(
> > "lgr 2,%0\n" /* Arg 1: fd */
> > "la 3,%1\n" /* Arg 2: &tid */
> > "lghi 4,4\n" /* Arg 3: sizeof(int) */
> > "svc 4\n" /* __NR_write SVC: */
> > /* After SVC no more registers are changed */
> > "0: j 0b\n" /* Loop here */
> > : : "d" (fd), "Q" (tid) : "2", "3", "4");
> > }
> >
> > >
> > > 45166 pts/0 S+ 0:00 | \_ python2 ./zdtm.py run -f h,ns -t zdtm/static/s390x_regs_check
> > > 45176 pts/0 S+ 0:00 | \_ ./zdtm_ct zdtm.py
> > > 45179 pts/0 S+ 0:00 | | \_ python2 zdtm.py
> > > 45182 pts/0 S+ 0:00 | | \_ python2 zdtm.py
> > > 45199 pts/0 S+ 0:00 | | \_ make --no-print-directory -C zdtm/static s390x_regs_check.pid
> > > 45214 pts/0 S+ 0:00 | | \_ ./s390x_regs_check --pidfile=s390x_regs_check.pid --outfile=s390x_regs_check.out
> > > 45215 ? Ss 0:00 | | \_ ./s390x_regs_check --pidfile=s390x_regs_check.pid --outfile=s390x_regs_check.out
> > > 45216 ? Rl 0:16 | | \_ ./s390x_regs_check --pidfile=s390x_regs_check.pid --outfile=s390x_regs_check.out
> > > 45219 pts/0 R+ 0:00 | \_ ps axf
> >
> > I probable will not be able to look into this the next two weeks.
> > Alice will be back next week. I hope she can help you then.
>
> The patch to fix the failing build is still not merged and the test
> still hangs once your inlined patch is applied.
I could reproduce the problem with the kernel that you have
provided. The following patch solved the problem, but we still
have a problem for uns:
=================== Run zdtm/static/s390x_regs_check in uns ====================
Start test
./s390x_regs_check --pidfile=s390x_regs_check.pid --outfile=s390x_regs_check.out
clone() failed: Invalid argument
make: *** [s390x_regs_check.pid] Error 1
############### Test zdtm/static/s390x_regs_check FAIL at start ################
##################################### FAIL #####################################
Looks like the ptrace_create() call has a problem in that case.
Here the patch that fixes "h" and "ns".
---
Subject: [PATCH] zdtm/s390x_regs_check: Fix wait() for threads
For older kernels (e.g. RHEL7 4.10) it seems that wait(NULL) after
ptrace(PTHREAD_ATTACH) does not work properly for threads that have
to be created via clone().
Fix this by using waitpid() with the __WALL flag.
>From the waitpid() man page:
__WALL (since Linux 2.4)
Wait for all children, regardless of type ("clone" or "non-clone").
Reported-by: Adrian Reber <areber at redhat.com>
Signed-off-by: Michael Holzheu <holzheu at linux.vnet.ibm.com>
---
test/zdtm/static/s390x_regs_check.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/test/zdtm/static/s390x_regs_check.c b/test/zdtm/static/s390x_regs_check.c
index a92679ab0..4854b534a 100644
--- a/test/zdtm/static/s390x_regs_check.c
+++ b/test/zdtm/static/s390x_regs_check.c
@@ -391,7 +391,10 @@ static void child_func(void)
static int ptrace_attach(pid_t pid)
{
if (ptrace(PTRACE_ATTACH, pid, 0, 0) == 0) {
- wait(NULL);
+ if (waitpid(pid, NULL, __WALL) < 0) {
+ pr_perror("Waiting for thread %d failed", pid);
+ return -1;
+ }
return 0;
}
pr_perror("Attach to thread %d failed", pid);
--
2.11.0
More information about the CRIU
mailing list