[CRIU] [PATCH] travis: catch core dump files in error cases
Andrei Vagin
avagin at virtuozzo.com
Wed Aug 24 12:46:53 PDT 2016
On Tue, Aug 23, 2016 at 05:12:19PM +0300, Pavel Emelyanov wrote:
> On 08/20/2016 03:26 AM, Andrei Vagin wrote:
> > From: Andrei Vagin <avagin at virtuozzo.com>
> >
> > It is very hard to investigate travis fails, when something is segfaulted.
> >
> > Let's add our own core file handler which will provide all required
> > information for us. Now test/abrt.sh shows a process tree,
> > process mappings, registers and backtraces.
> >
> > Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
> > ---
> > scripts/travis/travis-tests | 7 ++++++-
> > test/abrt.sh | 30 ++++++++++++++++++++++++++++++
> > test/zdtm.py | 22 ++++++++++++++++++++++
> > 3 files changed, 58 insertions(+), 1 deletion(-)
> > create mode 100755 test/abrt.sh
> >
> > diff --git a/scripts/travis/travis-tests b/scripts/travis/travis-tests
> > index 764dcb1..6976de2 100755
> > --- a/scripts/travis/travis-tests
> > +++ b/scripts/travis/travis-tests
> > @@ -1,12 +1,17 @@
> > #!/bin/sh
> > set -x -e
> >
> > +ulimit -c unlimited
> > +
> > cd ../../
> >
> > +service apport stop
> > +echo "|`pwd`/test/abrt.sh %P %p %s %e" > /proc/sys/kernel/core_pattern
> > +
> > apt-get update -qq
> > apt-get install -qq protobuf-c-compiler libprotobuf-c0-dev libaio-dev \
> > libprotobuf-dev protobuf-compiler python-ipaddr libcap-dev \
> > - libnl-3-dev gcc-multilib libc6-dev-i386
> > + libnl-3-dev gcc-multilib libc6-dev-i386 gdb bash
> > chmod a+x $HOME
> > export GCOV=1
> > make
> > diff --git a/test/abrt.sh b/test/abrt.sh
> > new file mode 100755
> > index 0000000..34f25b4
> > --- /dev/null
> > +++ b/test/abrt.sh
> > @@ -0,0 +1,30 @@
> > +#!/bin/bash -x
> > +
> > +pid=$1
> > +vpid=$2
> > +sig=$3
> > +comm=$4
> > +
> > +exec &>> /tmp/zdtm-core.log
> > +
> > +expr match "$comm" zombie00 && {
> > + cat > /dev/null
> > + exit 0
> > +}
> > +
> > +report="/tmp/zdtm-core-$pid-$comm"
> > +exec &> ${report}.txt
> > +
> > +ps axf
> > +ps -p $pid
> > +
> > +cat /proc/$pid/status
> > +ls -l /proc/$pid/fd
> > +cat /proc/$pid/maps
> > +exec 33< /proc/$pid/exe
> > +cat > $report.core
> > +
> > +echo 'bt
> > +i r
> > +disassemble $rip-0x10,$rip + 0x10
> > +' | gdb -c $report.core /proc/self/fd/33
> > diff --git a/test/zdtm.py b/test/zdtm.py
> > index 0bd8e3b..1bd38eb 100755
> > --- a/test/zdtm.py
> > +++ b/test/zdtm.py
> > @@ -1,6 +1,7 @@
> > #!/usr/bin/env python2
> > # vim: noet
> > import argparse
> > +import glob
> > import os
> > import subprocess
> > import time
> > @@ -102,6 +103,25 @@ def add_to_output(path):
> > fdo.write(buf)
> >
> >
> > +init_reports = set(glob.glob("/tmp/zdtm-core-*.txt"))
> > +
> > +
> > +def check_core_files():
>
> The whole function only makes sense if --report is turned on, doesn't it?
No, it isn't. We print the content of reports.
>
> > + reports = set(glob.glob("/tmp/zdtm-core-*.txt")) - init_reports
>
> Maybe name this cores, not reports?
/tmp/zdtm-core-*.txt is a crash report, it contains process list,
/proc/self/maps, back-trace, registers.
"init_reports" is not a good name. It should be prev_crash_report_list
>
> > + if not reports:
> > + return False
> > +
> > + while subprocess.Popen("ps axf | grep 'abrt\.sh'", shell = True).wait() == 0:
> > + time.sleep(1)
> > +
> > + for i in reports:
> > + add_to_report(i, os.path.basename(i))
> > + print_sep(i)
> > + print open(i).read()
> > + print_sep(i)
> > +
> > + return True
> > +
> > # Arch we run on
> > arch = os.uname()[4]
> >
> > @@ -1242,6 +1262,8 @@ class launcher:
> >
> > def finish(self):
> > self.__wait_all()
> > + if not opts['fault'] and check_core_files():
>
> Why not for faults? Just curious :)
>
> > + self.__fail = True
>
> O_o Can it happen that we have cores, but __fail is not set?
>
> > if self.__file_report:
> > self.__file_report.close()
> > if self.__fail:
> >
>
More information about the CRIU
mailing list