From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52808 invoked by alias); 6 Mar 2015 19:58:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 52703 invoked by uid 89); 6 Mar 2015 19:58:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 06 Mar 2015 19:58:09 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t26Jw70f003325 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 6 Mar 2015 14:58:08 -0500 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t26Jw60k024787 for ; Fri, 6 Mar 2015 14:58:07 -0500 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 0/6] Fix problems if inferior disappears while being debugged Date: Fri, 06 Mar 2015 19:58:00 -0000 Message-Id: <1425671886-7798-1-git-send-email-palves@redhat.com> X-SW-Source: 2015-03/txt/msg00179.txt.bz2 The gdb.threads/killed.exp test has a race that happened to trigger more often with my all-stop-non-stop series. On GNU/Linux, this test sometimes FAILs like this: (gdb) run Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/killed [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". ptrace: No such process. (gdb) Program terminated with signal SIGKILL, Killed. The program no longer exists. FAIL: gdb.threads/killed.exp: run program to completion (timeout) This is ptrace erroring out with ESRCH (thread is gone). We ignore this error explicitly in some places (more in GDBserver than in GDB), but not everywhere that it's needed. And it's not clear that ignoring is the best thing to do everywhere. So I thought of a different approach. Currently, when ptrace errors, we usually call perror_with_name, which just throws a generic error. The series replaces the perror_with_name calls with calls to a new throw_ptrace_error function that converts ESRCH to a new error/exception (THREAD_NOT_FOUND_ERROR), which then higher layers can catch and handle as appropriate. I then wrote a test that explicitly kills the inferior while it is being debugged, with "kill -9", and that uncovered even more problems... Both GDB and GDBserver internal error in some cases, like this on native/Linux: src/gdb/linux-nat.c:2590: internal-error: status_callback: Assertion `lp->status != 0' failed. and this on gdbserver/Linux: src/gdb/gdbserver/linux-low.c:972: A problem internal to GDBserver has been detected. kill_wait_lwp: Assertion `res > 0' failed. This series also addresses those issues. Pedro Alves (6): Move throw_perror_with_name to common/ Introduce throw_ptrace_error Fix race exposed by gdb.threads/killed.exp native/Linux: internal error if inferior disappears after stopped by breakpoint gdbserver/Linux: internal error when killing a process that is already gone Add test that exercises the inferior being killed while stopped under GDB gdb/Makefile.in | 6 +- gdb/aarch64-linux-nat.c | 13 +-- gdb/alphabsd-nat.c | 13 +-- gdb/amd64-linux-nat.c | 19 ++--- gdb/amd64bsd-nat.c | 19 ++--- gdb/arm-linux-nat.c | 9 ++- gdb/common/common-exceptions.h | 3 + gdb/common/errors.c | 8 ++ gdb/common/errors.h | 13 ++- gdb/config/aarch64/linux.mh | 2 +- gdb/config/alpha/alpha-linux.mh | 2 +- gdb/config/alpha/fbsd.mh | 2 +- gdb/config/alpha/nbsd.mh | 2 +- gdb/config/arm/linux.mh | 2 +- gdb/config/arm/nbsdelf.mh | 2 +- gdb/config/i386/fbsd.mh | 2 +- gdb/config/i386/fbsd64.mh | 2 +- gdb/config/i386/linux.mh | 2 +- gdb/config/i386/linux64.mh | 2 +- gdb/config/i386/nbsd64.mh | 2 +- gdb/config/i386/nbsdelf.mh | 2 +- gdb/config/i386/obsd.mh | 2 +- gdb/config/i386/obsd64.mh | 2 +- gdb/config/ia64/linux.mh | 2 +- gdb/config/m32r/linux.mh | 2 +- gdb/config/m68k/linux.mh | 2 +- gdb/config/m68k/nbsdelf.mh | 2 +- gdb/config/m68k/obsd.mh | 2 +- gdb/config/m88k/obsd.mh | 2 +- gdb/config/mips/linux.mh | 2 +- gdb/config/mips/nbsd.mh | 2 +- gdb/config/mips/obsd64.mh | 2 +- gdb/config/pa/hpux.mh | 2 +- gdb/config/pa/linux.mh | 2 +- gdb/config/pa/nbsd.mh | 2 +- gdb/config/pa/obsd.mh | 2 +- gdb/config/powerpc/aix.mh | 2 +- gdb/config/powerpc/fbsd.mh | 2 +- gdb/config/powerpc/linux.mh | 2 +- gdb/config/powerpc/nbsd.mh | 2 +- gdb/config/powerpc/obsd.mh | 2 +- gdb/config/powerpc/ppc64-linux.mh | 2 +- gdb/config/powerpc/spu-linux.mh | 2 +- gdb/config/s390/linux.mh | 2 +- gdb/config/sh/nbsd.mh | 2 +- gdb/config/sparc/fbsd.mh | 2 +- gdb/config/sparc/linux.mh | 2 +- gdb/config/sparc/linux64.mh | 2 +- gdb/config/sparc/nbsd64.mh | 2 +- gdb/config/sparc/nbsdelf.mh | 2 +- gdb/config/sparc/obsd64.mh | 2 +- gdb/config/tilegx/linux.mh | 2 +- gdb/config/vax/nbsdelf.mh | 2 +- gdb/config/vax/obsd.mh | 2 +- gdb/config/xtensa/linux.mh | 2 +- gdb/gdbserver/Makefile.in | 6 +- gdb/gdbserver/configure.srv | 2 +- gdb/gdbserver/linux-low.c | 59 ++++++++++---- gdb/gdbserver/utils.c | 6 +- gdb/hppanbsd-nat.c | 13 +-- gdb/hppaobsd-nat.c | 13 +-- gdb/i386-linux-nat.c | 27 ++++--- gdb/i386bsd-nat.c | 23 +++--- gdb/i386fbsd-nat.c | 3 +- gdb/inf-ptrace.c | 19 ++--- gdb/linux-nat.c | 43 ++++++++-- gdb/m32r-linux-nat.c | 7 +- gdb/m68kbsd-nat.c | 13 +-- gdb/m68klinux-nat.c | 12 +-- gdb/m88kbsd-nat.c | 7 +- gdb/mips-linux-nat.c | 19 ++--- gdb/mips64obsd-nat.c | 7 +- gdb/mipsnbsd-nat.c | 13 +-- gdb/nat/ptrace-utils.c | 49 +++++++++++ gdb/nat/ptrace-utils.h | 28 +++++++ gdb/obsd-nat.c | 9 ++- gdb/ppc-linux-nat.c | 63 ++++++++------- gdb/ppcfbsd-nat.c | 13 +-- gdb/ppcnbsd-nat.c | 13 +-- gdb/ppcobsd-nat.c | 13 +-- gdb/rs6000-nat.c | 3 +- gdb/s390-linux-nat.c | 26 +++--- gdb/shnbsd-nat.c | 7 +- gdb/sparc-nat.c | 15 ++-- gdb/spu-linux-nat.c | 3 +- gdb/testsuite/gdb.base/killed-outside.c | 34 ++++++++ gdb/testsuite/gdb.base/killed-outside.exp | 130 ++++++++++++++++++++++++++++++ gdb/tilegx-linux-nat.c | 6 +- gdb/utils.c | 8 -- gdb/vaxbsd-nat.c | 7 +- gdb/x86-linux-nat.c | 9 ++- gdb/xtensa-linux-nat.c | 12 +-- 92 files changed, 642 insertions(+), 293 deletions(-) create mode 100644 gdb/nat/ptrace-utils.c create mode 100644 gdb/nat/ptrace-utils.h create mode 100644 gdb/testsuite/gdb.base/killed-outside.c create mode 100644 gdb/testsuite/gdb.base/killed-outside.exp -- 1.9.3