From patchwork Thu May 24 12:44:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 27489 Received: (qmail 102127 invoked by alias); 24 May 2018 12:44:22 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 102045 invoked by uid 89); 24 May 2018 12:44:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=979 X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 24 May 2018 12:44:10 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A123A401EF0E; Thu, 24 May 2018 12:44:08 +0000 (UTC) Received: from localhost.localdomain (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A8331006EBC; Thu, 24 May 2018 12:44:07 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Cc: Saagar Jha Subject: [PATCH] Fix macOS null pointer dereference Date: Thu, 24 May 2018 13:44:07 +0100 Message-Id: <20180524124407.4324-1-palves@redhat.com> Saagar, could you give this a try? 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 * 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); }