From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12381 invoked by alias); 29 Jul 2015 11:23:06 -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 11699 invoked by uid 89); 29 Jul 2015 11:23:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: mail-ob0-f172.google.com Received: from mail-ob0-f172.google.com (HELO mail-ob0-f172.google.com) (209.85.214.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 29 Jul 2015 11:23:05 +0000 Received: by obnw1 with SMTP id w1so4654072obn.3 for ; Wed, 29 Jul 2015 04:23:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=RCYFTBfvAJPLDo8q7wTGyBCEtsVlWjhR0cXFtBiGK9M=; b=Tc+Q/OREzPgW8U2yBVvvbIpTXz5XSE85QgsaSpJQaIMdEfQV3HDnwDiW36QFPOLAR6 0tWb7om8+/ErRVXGd4tMevZSzMwmbhKIG7PtToMsAy8ldfXdBHU0IVKtHlvfrFe5CoCG r2LIKGVZk0kVqQyuTM+419/E6YMUIRDXWe9L6sQthf/3+skexsVb57QpVLdHIN+vxqci aM6g3gfj8Ku4jvIZZe89LqNjg4ATgJygPbAEC+bYzvmUtbzH32M+UKBnjYmwSMJffY0L BR3n+clAcptVySc4sCiPsQNA1Bl92QnakyNfV8f96EWhQ0aBRdFsYfN7dhyStUeIYshh E4dQ== X-Gm-Message-State: ALoCoQnz9al0ZsghJ7p0G0uCl2VGlfoctUEMs5nmN8sQnOJftjf02BPz0oCv/IRasDdl1iVDJ6vH X-Received: by 10.182.252.97 with SMTP id zr1mr39210762obc.28.1438168983560; Wed, 29 Jul 2015 04:23:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.56.202 with HTTP; Wed, 29 Jul 2015 04:22:44 -0700 (PDT) In-Reply-To: <55B8134A.9020308@redhat.com> References: <1438115396-7256-1-git-send-email-patrick@parcs.ath.cx> <55B8134A.9020308@redhat.com> From: Patrick Palka Date: Wed, 29 Jul 2015 11:23:00 -0000 Message-ID: Subject: Re: [PATCH] Fix assert failure in invocation of "[kill|detach] inferiors 1" To: Pedro Alves Cc: "gdb-patches@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2015-07/txt/msg00861.txt.bz2 On Tue, Jul 28, 2015 at 7:42 PM, Pedro Alves wrote: > On 07/28/2015 09:29 PM, Patrick Palka wrote: >> When only the dummy PID 0 inferior exists, invoking either of the above >> commands triggers the following assert failure: >> >> .../binutils-gdb/gdb/thread.c:514: internal-error: any_thread_of_process: Assertion `pid != 0' failed. >> >> The fix is straightforward. Tested on x86_64 Debian Stretch. > > Thanks. > >> >> gdb/ChangeLog: >> >> * inferior.c (detach_inferior_command): Don't call >> any_thread_of_process when pid is 0. >> (kill_inferior_command): Likewise. >> >> gdb/testsuite/ChangeLog: >> >> * gdb.base/no-inferiors.exp: New test file. >> --- >> gdb/inferior.c | 12 ++++++++++-- >> gdb/testsuite/gdb.base/no-inferiors.exp | 24 ++++++++++++++++++++++++ >> 2 files changed, 34 insertions(+), 2 deletions(-) >> create mode 100644 gdb/testsuite/gdb.base/no-inferiors.exp >> >> diff --git a/gdb/inferior.c b/gdb/inferior.c >> index 5e98df5..ff85a1f 100644 >> --- a/gdb/inferior.c >> +++ b/gdb/inferior.c >> @@ -626,7 +626,11 @@ detach_inferior_command (char *args, int from_tty) >> >> pid = gdb_inferior_id_to_pid (num); >> >> - tp = any_thread_of_process (pid); >> + if (pid != 0) >> + tp = any_thread_of_process (pid); >> + else >> + tp = 0; > > Should be tp = NULL. Oops, ok. > > This is old code that predates the multi-executable support > (6c95b8df7fef), and was never really updated since. Guess > not many people use it... I see. Though I think the regression may have been introduced more recently, by commit 32990ad, when the gdb_assert in question was added. > > Doesn't make that much sense to say "has no threads" > nowadays. I think this should give out a warning similar > to the error "detach_command" throws, like: > > + if (pid == 0) > + { > + warning (_("Inferior ID %s is not being run."), num); > + continue; > + } > > tp = any_thread_of_process (pid); > if (!tp) > { > warning (_("Inferior ID %d has no threads."), num); > continue; > } > > The "has no threads" case is then more of an internal error, > but there's no need to be so drastic, so leave it as is. > > (Likewise for kill, of course.) > > OK with that change. Ah, so the internal error may also be triggered by passing to these commands an inferior that is not being run, not just by passing the initial dummy inferior. I will change the test file to cover these bases. I notice that "[kill|attach] inferiors" has no test coverage at all, so this will be a good time to add some.