From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 50492 invoked by alias); 29 Jun 2018 19:31:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 50425 invoked by uid 89); 29 Jun 2018 19:31:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.4 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=thread.c, threadc, Assertion, UD:thread.c 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; Fri, 29 Jun 2018 19:31:36 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7DAA37DAC6; Fri, 29 Jun 2018 19:31:34 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id D12147C4F; Fri, 29 Jun 2018 19:31:33 +0000 (UTC) Subject: Re: [RFA] Fix crash in "run" on macOS when gdb is not signed To: Tom Tromey , gdb-patches@sourceware.org References: <20180628180257.29883-1-tom@tromey.com> From: Pedro Alves Message-ID: <1d40e422-08f4-30c1-de10-bd63396acb0b@redhat.com> Date: Fri, 29 Jun 2018 19:31:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180628180257.29883-1-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-06/txt/msg00730.txt.bz2 On 06/28/2018 07:02 PM, Tom Tromey wrote: > On macOS, when gdb is not code-signed, it will throw an exception from > darwin_attach_pid. However, gdb also then crashes: > > thread.c:93: internal-error: struct thread_info *inferior_thread(): Assertion `tp' failed. > > I think the problem here is that darwin_attach_pid does not clean up > inferior_ptid and inf->pid on failure. This leads to a situation > where gdb tries to find a thread, but cannot. > > In other cases, gdb would mourn the inferior at this point; but here > this is not possible because the target has not been pushed. Instead > this patch works by simply updating the inferior and inferior_ptid on > failure. > > Tested by building an unsigned gdb on macOS and trying to run an > inferior. I'd try also with "attach", see if something else needs cleaning up / unwinding. > diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c > index 7dccce73926..6fb108846d0 100644 > --- a/gdb/darwin-nat.c > +++ b/gdb/darwin-nat.c > @@ -1583,77 +1583,92 @@ darwin_attach_pid (struct inferior *inf) > darwin_inferior *priv = new darwin_inferior; > inf->priv.reset (priv); > > - kret = task_for_pid (gdb_task, inf->pid, &priv->task); > - if (kret != KERN_SUCCESS) > + TRY > { [snip reindent] > + } > + CATCH (ex, RETURN_MASK_ALL) > + { > + inf->pid = 0; If you try this with MI as is, I think gdb will output a -thread-group-started notification, and then an ^error. You may want to call exit_inferior instead so that gdb outputs a matching -thread-group-exited. Otherwise looks fine to me. Thanks, Pedro Alves