Message ID | 0b900391-f06d-278c-cbed-b89b207bd12e@redhat.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 5618 invoked by alias); 18 Apr 2018 11:21:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 5606 invoked by uid 89); 18 Apr 2018 11:21:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=falling 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; Wed, 18 Apr 2018 11:21:38 +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 1C1484022909; Wed, 18 Apr 2018 11:21:37 +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 9AD08111CA18; Wed, 18 Apr 2018 11:21:34 +0000 (UTC) Subject: Re: [PATCH 31/40] target_ops/C++: Base FreeBSD target To: John Baldwin <jhb@freebsd.org> References: <20180414190953.24481-1-palves@redhat.com> <2651054.rGX2nUqyEc@ralph.baldwin.cx> <4c3b320e-ecbe-4e97-9ee4-91cacca60b8d@redhat.com> <2336080.G2aX46TNlR@ralph.baldwin.cx> Cc: gdb-patches@sourceware.org From: Pedro Alves <palves@redhat.com> Message-ID: <0b900391-f06d-278c-cbed-b89b207bd12e@redhat.com> Date: Wed, 18 Apr 2018 12:21:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <2336080.G2aX46TNlR@ralph.baldwin.cx> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit |
Commit Message
Pedro Alves
April 18, 2018, 11:21 a.m. UTC
On 04/18/2018 01:37 AM, John Baldwin wrote: > On Tuesday, April 17, 2018 06:07:37 PM Pedro Alves wrote: >> On 04/17/2018 05:05 PM, John Baldwin wrote: >>> On Saturday, April 14, 2018 08:09:44 PM Pedro Alves wrote: >>>> The >>>> >>>> $architecture x NetBSD/OpenBSD/FreeBSD >>>> >>>> support matrix complicates things a bit. There's common BSD target >>>> code, and there's common architecture-specific code shared between the >>>> different BSDs. Current, all that is stiched together to form a final >>>> target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target >>>> functions etc. >>>> >>>> Introduces a fbsd_nat_target base/prototype target. To be used in >>>> following patches. >>> >>> I will do some tests of FreeBSD/amd64 first and let you know what I find. >> >> Thank you! > > I've pushed a target_ops-cxx branch to github.com/bsdjhb/gdb.git that has > some small fixups (compile fixes). Thank you! > I've built the amd64, i386, arm, and > aarch64 FreeBSD native targets so far. Simple testing of the the amd64 > and i386 binaries seems to work, but I encountered a new test failure > in the testsuite for FreeBSD/amd64 that is a bit odd. In particular, > I get a core dump running 'info set' when it tries to display the > current setting of whether ASLR is disabled. Looking at the core of gdb: Ah, I wasn't seeing this because the Linux target implements the supports_disable_randomization method. If I hack that away, I can reproduce the crash. > > Program terminated with signal SIGSEGV, Segmentation fault. > #0 0x0000000000d3a7d4 in target_ops::supports_disable_randomization ( > this=0x28d4c68 <the_amd64_fbsd_nat_target>) > at ../../gdb/target-delegates.c:2732 > 2732 return this->beneath->supports_disable_randomization (); > ... > > From the stack trace we can see that it already bounced down to the dummy > target which calls find_default_supports_disable_randomization. That > finds the native "run" target and invokes its method without pushing > it onto the stack. I think before if a native target didn't support ASLR > at all it just didn't set the function pointer and no harm was done. > Now the function pointer is effectively always set but to something that > assumes 'beneath' is valid. I'm not quite sure how you want to fix this. > The simple solution is to change the default method to return false if > beneath is NULL, but I'm not quite sure that fits in with the design this > branch is aiming for. Thanks for the analysis, that helps. There's a small set of target methods that must always be implemented by native targets, to avoid falling down to the target beneath (since the target may not be pushed when the method is called). See target.c:complete_target_initialization in current master. Since all native targets inherit from inf-child (just like in current master), in the C++ version, we can override it there. Like below. This fixes it for me. Thanks, Pedro Alves
Comments
On 04/18/2018 12:21 PM, Pedro Alves wrote: > On 04/18/2018 01:37 AM, John Baldwin wrote: >> I've pushed a target_ops-cxx branch to github.com/bsdjhb/gdb.git that has >> some small fixups (compile fixes). > > Thank you! I've now merged/squashed those fixes to the patches in the branch, and added your name to the WIP ChangeLog entry. I diff my branch against yours to double-checked whether I was missing anything, then rebased on top of current master. I force-pushed the result to users/palves/target_ops-cxx on sourceware.org. Thanks again. > There's a small set of target methods that must always be > implemented by native targets, to avoid falling down to the > target beneath (since the target may not be pushed when the > method is called). See target.c:complete_target_initialization > in current master. Since all native targets inherit from inf-child > (just like in current master), in the C++ version, we can override > it there. Like below. This fixes it for me. > > diff --git c/gdb/inf-child.h w/gdb/inf-child.h > index d3f8b71589..956cee2a0a 100644 > --- c/gdb/inf-child.h > +++ w/gdb/inf-child.h > @@ -72,6 +72,7 @@ public: > target that can run. */ > bool can_async_p () override { return false; } > bool supports_non_stop () override { return false; } > + bool supports_disable_randomization () override { return false; } > > char *pid_to_exec_file (int pid) override; This is in the branch too now. Thanks, Pedro Alves
On Wednesday, April 18, 2018 03:20:19 PM Pedro Alves wrote: > On 04/18/2018 12:21 PM, Pedro Alves wrote: > > On 04/18/2018 01:37 AM, John Baldwin wrote: > > >> I've pushed a target_ops-cxx branch to github.com/bsdjhb/gdb.git that has > >> some small fixups (compile fixes). > > > > Thank you! > > I've now merged/squashed those fixes to the patches in the branch, > and added your name to the WIP ChangeLog entry. > > I diff my branch against yours to double-checked whether I was > missing anything, then rebased on top of current master. > > I force-pushed the result to users/palves/target_ops-cxx on sourceware.org. > > Thanks again. Thanks for the explanation of the proper fix. I've pulled the updated branch and FreeBSD/amd64 has basically the same test results as master now. (There are a few differences but I think they are due to timing issues/races in the tests rather than actual behavioral differences.) There are a few other platforms I haven't built yet (FreeBSD/mips and FreeBSD/powerpc) but I'm fine with fixing those post-commit if there are any fixes needed. If I am able to test them before you merge this in I'll send you any needed patches.
diff --git c/gdb/inf-child.h w/gdb/inf-child.h index d3f8b71589..956cee2a0a 100644 --- c/gdb/inf-child.h +++ w/gdb/inf-child.h @@ -72,6 +72,7 @@ public: target that can run. */ bool can_async_p () override { return false; } bool supports_non_stop () override { return false; } + bool supports_disable_randomization () override { return false; } char *pid_to_exec_file (int pid) override;