Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Patrick Palka <patrick@parcs.ath.cx>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Fix assert failure in invocation of "[kill|detach] inferiors 1"
Date: Tue, 28 Jul 2015 23:42:00 -0000	[thread overview]
Message-ID: <55B8134A.9020308@redhat.com> (raw)
In-Reply-To: <1438115396-7256-1-git-send-email-patrick@parcs.ath.cx>

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.

This is old code that predates the multi-executable support
(6c95b8df7fef), and was never really updated since.  Guess
not many people use it...

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.

Thanks,
Pedro Alves


  reply	other threads:[~2015-07-28 23:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-28 20:30 Patrick Palka
2015-07-28 23:42 ` Pedro Alves [this message]
2015-07-29 11:23   ` Patrick Palka
2015-07-29 11:38     ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55B8134A.9020308@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=patrick@parcs.ath.cx \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox