public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix macOS null pointer dereference
@ 2018-05-24 13:33 Pedro Alves
  2018-06-04 11:32 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2018-05-24 13:33 UTC (permalink / raw)
  To: gdb-patches; +Cc: Saagar Jha

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix macOS null pointer dereference
  2018-05-24 13:33 [PATCH] Fix macOS null pointer dereference Pedro Alves
@ 2018-06-04 11:32 ` Pedro Alves
  2018-06-05 12:31   ` Saagar Jha
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2018-06-04 11:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Saagar Jha

On 05/24/2018 01:44 PM, Pedro Alves wrote:
> Saagar, could you give this a try?

I've merged this, given the discussion on the bug.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix macOS null pointer dereference
  2018-06-04 11:32 ` Pedro Alves
@ 2018-06-05 12:31   ` Saagar Jha
  0 siblings, 0 replies; 3+ messages in thread
From: Saagar Jha @ 2018-06-05 12:31 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Great, that’s one less thing we need to worry about now.

Saagar Jha

> On Jun 4, 2018, at 04:32, Pedro Alves <palves@redhat.com> wrote:
> 
> On 05/24/2018 01:44 PM, Pedro Alves wrote:
>> Saagar, could you give this a try?
> 
> I've merged this, given the discussion on the bug.
> 
> Thanks,
> Pedro Alves

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-05 12:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-24 13:33 [PATCH] Fix macOS null pointer dereference Pedro Alves
2018-06-04 11:32 ` Pedro Alves
2018-06-05 12:31   ` Saagar Jha

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).