public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Cc: Saagar Jha <saagar@saagarjha.com>
Subject: [PATCH] Fix macOS null pointer dereference
Date: Thu, 24 May 2018 13:33:00 -0000	[thread overview]
Message-ID: <20180524124407.4324-1-palves@redhat.com> (raw)

Saagar, could you give this a try?

<https://sourceware.org/bugzilla/show_bug.cgi?id=22960#c4> reports
that macOS gdb crashes with a null pointer dereference in
push_target(struct target_ops *).  This commit fixes that.

The problem is that commit f6ac5f3d63e0 ("Convert struct target_ops to
C++") left the darwin_ops global uninitialized.

We don't need that global anymore, we can use the (new)
get_native_target function instead for the same effect.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <palves@redhat.com>

	* darwin-nat.c (darwin_ops): Delete.
	(darwin_attach_pid): Use get_native_target.
---
 gdb/darwin-nat.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 0b1a4910a3..ed1ed32898 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -97,9 +97,6 @@ static void darwin_deallocate_exception_ports (darwin_inferior *inf);
 static void darwin_setup_exceptions (struct inferior *inf);
 static void darwin_deallocate_threads (struct inferior *inf);
 
-/* Target operations for Darwin.  */
-static struct target_ops *darwin_ops;
-
 /* Task identifier of gdb.  */
 static task_t gdb_task;
 
@@ -1656,6 +1653,7 @@ darwin_attach_pid (struct inferior *inf)
 
   darwin_setup_exceptions (inf);
 
+  target_ops *darwin_ops = get_native_target ();
   if (!target_is_pushed (darwin_ops))
     push_target (darwin_ops);
 }
-- 
2.14.3

             reply	other threads:[~2018-05-24 12:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-24 13:33 Pedro Alves [this message]
2018-06-04 11:32 ` Pedro Alves
2018-06-05 12:31   ` Saagar Jha

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=20180524124407.4324-1-palves@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=saagar@saagarjha.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).