Fix macOS null pointer dereference
authorPedro Alves <palves@redhat.com>
Mon, 4 Jun 2018 11:26:39 +0000 (12:26 +0100)
committerPedro Alves <palves@redhat.com>
Mon, 4 Jun 2018 11:26:39 +0000 (12:26 +0100)
<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.

gdb/ChangeLog
gdb/darwin-nat.c

index f3b616fef464bba0a9cf8fde539298b39e474a3c..a292f4c0569e089789ebd8ef0c3ff9199ca7e45b 100644 (file)
@@ -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.
index 0b1a4910a3097f448a6e60b5b7f092be30e9f2cc..ed1ed32898996c5c2a833aa9b60ade675022c269 100644 (file)
@@ -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);
 }
This page took 0.028945 seconds and 4 git commands to generate.