From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [RFA] Fix crash in "run" on macOS when gdb is not signed
Date: Fri, 29 Jun 2018 19:31:00 -0000 [thread overview]
Message-ID: <1d40e422-08f4-30c1-de10-bd63396acb0b@redhat.com> (raw)
In-Reply-To: <20180628180257.29883-1-tom@tromey.com>
On 06/28/2018 07:02 PM, Tom Tromey wrote:
> On macOS, when gdb is not code-signed, it will throw an exception from
> darwin_attach_pid. However, gdb also then crashes:
>
> thread.c:93: internal-error: struct thread_info *inferior_thread(): Assertion `tp' failed.
>
> I think the problem here is that darwin_attach_pid does not clean up
> inferior_ptid and inf->pid on failure. This leads to a situation
> where gdb tries to find a thread, but cannot.
>
> In other cases, gdb would mourn the inferior at this point; but here
> this is not possible because the target has not been pushed. Instead
> this patch works by simply updating the inferior and inferior_ptid on
> failure.
>
> Tested by building an unsigned gdb on macOS and trying to run an
> inferior.
I'd try also with "attach", see if something else needs
cleaning up / unwinding.
> diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
> index 7dccce73926..6fb108846d0 100644
> --- a/gdb/darwin-nat.c
> +++ b/gdb/darwin-nat.c
> @@ -1583,77 +1583,92 @@ darwin_attach_pid (struct inferior *inf)
> darwin_inferior *priv = new darwin_inferior;
> inf->priv.reset (priv);
>
> - kret = task_for_pid (gdb_task, inf->pid, &priv->task);
> - if (kret != KERN_SUCCESS)
> + TRY
> {
[snip reindent]
> + }
> + CATCH (ex, RETURN_MASK_ALL)
> + {
> + inf->pid = 0;
If you try this with MI as is, I think gdb will output a
-thread-group-started notification, and then an ^error.
You may want to call exit_inferior instead so that
gdb outputs a matching -thread-group-exited.
Otherwise looks fine to me.
Thanks,
Pedro Alves
next prev parent reply other threads:[~2018-06-29 19:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-28 18:03 Tom Tromey
2018-06-29 19:31 ` Pedro Alves [this message]
2018-07-02 15:33 ` Tom Tromey
2018-07-03 14:16 ` Pedro Alves
2018-07-04 11:46 ` Pedro Alves
2018-07-04 17:34 ` Tom Tromey
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=1d40e422-08f4-30c1-de10-bd63396acb0b@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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