This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Fix macOS null pointer dereference
- From: Pedro Alves <palves at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 4 Jun 2018 11:27:49 -0000
- Subject: [binutils-gdb] Fix macOS null pointer dereference
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=59f413d5412217c5c6f9e25d0279a1997426d60a
commit 59f413d5412217c5c6f9e25d0279a1997426d60a
Author: Pedro Alves <palves@redhat.com>
Date: Mon Jun 4 12:26:39 2018 +0100
Fix macOS null pointer dereference
<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:
2018-06-04 Pedro Alves <palves@redhat.com>
* darwin-nat.c (darwin_ops): Delete.
(darwin_attach_pid): Use get_native_target.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/darwin-nat.c | 4 +---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f3b616f..a292f4c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2018-06-04 Pedro Alves <palves@redhat.com>
+
+ * darwin-nat.c (darwin_ops): Delete.
+ (darwin_attach_pid): Use get_native_target.
+
2018-06-04 Alan Hayward <alan.hayward@arm.com>
* aarch64-tdep.c (aarch64_get_tdesc_vq): Use uint64_t for VQ.
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 0b1a491..ed1ed32 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);
}