From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2043.outbound.protection.outlook.com [40.107.104.43]) by sourceware.org (Postfix) with ESMTPS id 13CDF3858025 for ; Wed, 4 May 2022 09:52:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 13CDF3858025 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=TG9T0S2HEr3PHLG4pbGOLv4FAvSI340ZZR0DsLKWN5I1utCccBmsHXrUvnyx6HppUl1+BXi8pyLuw1IY8Grb/vr++ZMwqZIGlVY5Ml2sySaMyXfed3MDqyycd8roo8M4ppCAJnTfjZotEV/NTnQJ8jGWa2yxTPeSrYeepFY5MMnAXy36+LCNGKUscYY2Tjz7UNcefSFz7/WahtQl0OAgNRGZfQZNhHPKp1HVh3hxlK1urLS/qTDdhOE2FxXJ0g1BlNHTPEeP/WUDKNYTzbr/HShCBJ94FtDjEDzHOtddAqF18TxoaOrGCYCu8JbTBazbxZci7tsnKkLjdxjQfa75MQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Zq3ImQOtSIOwuQSAkvf2t4thY8bIU7Zu6RtWt+rExBo=; b=l/C1LHvqNOoItEFbtlBA5MA1obZaaHrff8HK94v7YsDtkGlZBQVtuOgfodt7KpolgRUKBVbYFeX0U/c0QE1xibHi3ikAfJ3ZupyTSw2044Jvm2iWR8kdBF7fnW9tu3TJVEme/1v1ObzB4vLh5y7uYgeqm0nuDodZWf+H9Kf7DlmC8scaoZwdzQP+Hxa21ck81i9DakqxYq1aPkOrdNAvkD5IhQ/BFYyqK0DcWotvAiGXdmB3m1WMX5oPQX4FjMzpPsASPFn3HOQ4pcQFZF8XpftS0Qy7cTVfnUL4FXY8UfUvOgRUYKNJYTlTByLYQ5gteY42cU6BcBKTjZbOzESPog== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from DB6PR07CA0104.eurprd07.prod.outlook.com (2603:10a6:6:2c::18) by VI1PR08MB5518.eurprd08.prod.outlook.com (2603:10a6:803:13a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.24; Wed, 4 May 2022 09:52:53 +0000 Received: from DBAEUR03FT035.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2c:cafe::21) by DB6PR07CA0104.outlook.office365.com (2603:10a6:6:2c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.6 via Frontend Transport; Wed, 4 May 2022 09:52:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT035.mail.protection.outlook.com (100.127.142.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.15 via Frontend Transport; Wed, 4 May 2022 09:52:52 +0000 Received: ("Tessian outbound ac9bb5dd84f6:v118"); Wed, 04 May 2022 09:52:52 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 003f02be95bf74bf X-CR-MTA-TID: 64aa7808 Received: from ed32e6674c7d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id DC7E0684-44EF-41BA-8436-3F56AA5C6DED.1; Wed, 04 May 2022 09:52:46 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ed32e6674c7d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 04 May 2022 09:52:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z3q8Prix2m3tr1r4PL9CB+FMNfElB+tEkA9HywhymkFPTP4D6lANtgLAVtx9hIH/+t1r1iXBFzk0LEn9BSMWCCaurnpEL9qfvk9cS06OnWcSxIgKOnsOG4HrvPIrAOiAGOAX39dH/j+NEnLHy8Ddd5pNMxh0LCoYCRennmQArmtu5fxFym5PNK1un0JdMqYQNt+xiHjbLSO6Ps3/L9Upa0/BFUGjDDN6quhJocRsHEi+Lr8zWNsVvbM0acl80sgI4yyyawcDEsmtPq+NnUCQGMEqgUi2QYv6pkdjPGQyUmF2yLqiAzqyNsWwz9/YpZmbOsXYvwSyCUM5+UQISQk8cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Zq3ImQOtSIOwuQSAkvf2t4thY8bIU7Zu6RtWt+rExBo=; b=FeLwJ8YO/tTwIiYZSti2zu3+N45casX6RuemyFYQrxszfzFDI2de1cQs1PKMn2252uWXxyQSsxTjUC1fy4klPYwQeh+Vl3lTzGym2Zn2QeTpOUU/KSHHt9o2/SZh76+4xBe9X5M+73+v40gu5CT95l2AwRr8A2m9ra1T6kLjQ73KbcJ3dDWD3y+BXkfHh7jIYgtLHzfVneaV/yeZTbOdtiocbIeFOUsOPDCjkAq6AYfRfG/PJzdt3MK16XRIWp2KZvKESZhwiM6mC0ZzzhoR3faaASATEdyPmGoZUG/79iknTmKXAme2z84TKSrCfffWuevGDim9SSjXpi5ZbOS7Pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) by AM7PR08MB5398.eurprd08.prod.outlook.com (2603:10a6:20b:103::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.24; Wed, 4 May 2022 09:52:44 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::7080:6233:cf8f:a8a6]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::7080:6233:cf8f:a8a6%7]) with mapi id 15.20.5206.025; Wed, 4 May 2022 09:52:44 +0000 Message-ID: <48db3b2b-46e3-1f30-2443-7d4b406b4c46@arm.com> Date: Wed, 4 May 2022 10:52:43 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH 0/2] Fix gdbserver/linux memory access regression Content-Language: en-US To: Pedro Alves , gdb-patches@sourceware.org References: <20220419224739.3029868-1-pedro@palves.net> <26ee78d5-d9ff-3ec3-5767-c6ae8cd5afa0@palves.net> <082d3a0a-f6a4-0e40-4e27-623a9949186c@arm.com> <51c7d9e9-7d84-f826-be2d-be559847da9b@palves.net> From: Luis Machado In-Reply-To: <51c7d9e9-7d84-f826-be2d-be559847da9b@palves.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO2P265CA0472.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a2::28) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 3c64baff-aeda-446e-f7f3-08da2db3db53 X-MS-TrafficTypeDiagnostic: AM7PR08MB5398:EE_|DBAEUR03FT035:EE_|VI1PR08MB5518:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: GrIAHH5sxkLuedqbSoRamuhL4UcrdQPOxrC/3BgJDNSZzS65Rtoxpz+0y3NmEfoTbQ2SLSDybvY20bAfCu31ummKuNMZvyQP2IFUNbEo7HXdhowe/z4Mwn3MJaK+NGd9NwQjMdZtnxPGR3vmz7GXM1miXrOZqzfuqPUZmuzEJpEAUCMTnyGWbmXsuGoVedN+IrfnFMbgxIQn5yTqd94mc3ZcPKNCiBo9FJYEfGKnT3353jYznPYl5KxYVHsF8cc5hEPluWO3RM0JjUlriTqJjVic4i5oZzav/ZIrJY5arUUlwLq5hXLNpOdYUunQqV11nDEq9wo3O5RDMOtm1ay73upgm1tbTkXRat/OB8yjmyFBDze/+BXyfthI/PBq30C1cirAoulaqXiWRA0fBEXtHhMhdtR1FnI+N9RcDw7n+gOCdIWhTuWft0GuIw/JRPOfz99Bv2u+57KowhGEXlG6jVXDSEEJ6fxkjx9wpYAczOLf/j/1JmLOp1409TDDu5ci+KdPT/jeN/ISKeUENHDHN9G291znxDuHulWiX8rRvnt9tBuM/Gox/VumT9wlwIFMObbHXSbZBkxI4I8XgiXgn6wTsT40z8aHGod3lzqw0R+GGblJncLIhOJcxQGvPM6S8Sh2dyGVY1yIgdaBLCtzeALyXrsE9JGzLerweg3e+fwIo56oc6R+5F660Mup4fm3XBZVH8zsCFCmuUok0JJuksOfQRFqkbuVvFIK95VZN/XBx1JNRrXSJsRZYdwU5/+YUIkVWMh+sTwQcE4sxCQmW4yfhzaZ/P0BeVDn/BnK5FZjSgCrOnzN3AIi77Z4M1eQ X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB3919.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(316002)(66946007)(66556008)(66476007)(36756003)(84970400001)(508600001)(6486002)(83380400001)(26005)(2906002)(86362001)(8676002)(8936002)(44832011)(5660300002)(38100700002)(31696002)(6512007)(6506007)(53546011)(2616005)(31686004)(186003)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5398 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT035.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 5259dda3-17bc-4707-f469-08da2db3d65b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CQ5TZrt4S/rFLZDJiDDVeB8IHsmDZ8knzkVjJp90/fZ13j+KljTMxgDhegHAW7mmXwWAMnCIUeNIRNM3zo1pxoj2ofLtzfIMr2af8be4S5/7uhSnDnur5Ujuz/PVwrdhsWhoUWXCPw4duQowpn7d6KojFzJ7oRuIjr1JhYZ/g9LRpRYju+OmfjCdp2sro6FqzrGxkvMexqDkxmRdQutnVebaIu3bhkPS1PI+rpdT5Kn/tRWrmCbU2Q4ZNoHQjpd/U7NpxFxxbPoR7yNNojjDmpK/e5dd4anuNSLcwhtc/jGgPpGEbFc6Z3DXRyYGjaLhxSSX1yplON68/IG6RTSfBYrRGTlvlfqz61hepOca751hsbWf5bwdC6Qw6Su8TFbddwELb37KBSg4q2RbhYLulFUgeplA83Q8m21k+YoRNIqXk4qC7EgHJlLjN2ap2WWdK1nLkdMW0ZVZ4hz1NthhA1fTZ+oH+X0PJVfW67zFtta4kB/rCOvAFuE4LmTmEszfMoo8rjeUMB/X77kdue/J6VDW/3JHg4BROfpwOD0EkCWWsalJdx+5bcc3YAthyJVAHpRT0Gd7Q5/EZDyJt/Y4bRqd9dY3fPJQLkZSC6VOAvlpGMhS7J8TwCV/4hv6mPM9khxEgKeOlHuFwiqrC9ra2AelXO1TizCzUm7Qv2j0CQqHMtP+sNxuNs7JQ32ImiF226gQ82znpWzCfdZryfTHAoEzfc0R3oAPNYSD01AATPbi6MQDqnKJhXAEaZfiwPx7Oip61IJsnxRJLXHDAO2Y0arjiEPNRYzBUVjmbGD8sDI= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(83380400001)(5660300002)(6506007)(44832011)(53546011)(186003)(316002)(6486002)(36860700001)(36756003)(508600001)(8936002)(2906002)(31686004)(82310400005)(86362001)(356005)(47076005)(81166007)(336012)(31696002)(84970400001)(40460700003)(70586007)(70206006)(8676002)(26005)(6512007)(2616005)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2022 09:52:52.8455 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3c64baff-aeda-446e-f7f3-08da2db3db53 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT035.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5518 X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY, WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 May 2022 09:53:01 -0000 On 5/4/22 10:45, Pedro Alves wrote: > On 2022-05-04 10:42, Luis Machado wrote: >> On 5/4/22 10:11, Luis Machado via Gdb-patches wrote: >>> On 5/3/22 15:24, Pedro Alves wrote: >>>> On 2022-04-19 23:47, Pedro Alves wrote: >>>>> The recent change to make GDBserver always access memory via >>>>> /proc/pid/mem caused a regression in >>>>> gdb.threads/access-mem-running-thread-exit.exp that I somehow missed. >>>>> This is actually a pre-existing GDBserver issue being now exposed. >>>>> >>>>> Patch #2 fixes the GDBserver bug. >>>>> >>>>> Patch #1 fixes the gdb.threads/access-mem-running-thread-exit.exp >>>>> testcase itself -- it doesn't run properly against >>>>> --target_board=native-extended-gdbserver today. >>>>> >>>> >>>> I'm pushing this in. >>> >>> Just a heads-up, this seems to have regressed a few gdb.multi/*.exp tests for aarch64-linux. >>> >>> I see the following internal error for gdb.multi/multi-target-continue.exp for example: >>> >>> Starting program: binutils-gdb/gdb/testsuite/outputs/gdb.multi/multi-target-continue/multi-target-continue ^M >>> Error in re-setting breakpoint 2: Remote connection closed^M >>> ../../../repos/binutils-gdb/gdb/thread.c:85: internal-error: inferior_thread: Assertion `current_thread_ != nullptr' failed.^M >>> A problem internal to GDB has been detected,^M >>> further debugging may prove unreliable. >>> >>> I haven't investigated this yet. >> >> Ok. I tracked this down to gdbserver crashing when trying to fetch the register cache using a nullptr for the thread pointer. This happens when trying to read memory, then the backend goes to try to figure out if it is 64-bit and then eventually tries to fetch the regcache with current_thread (nullptr). >> >> I'm guessing we should really be using the process pointer if there isn't a valid thread pointer to fetch the register data. >> > > Can you show a backtrace? If this is when reading memory, what code cares whether it's 64-bit? Reading memory > out of /proc/pid/mem should not care about that. Here it is: #0 thread_regcache_data (thread=thread@entry=0x0) at ../../../repos/binutils-gdb/gdbserver/inferiors.cc:120 #1 0x0000aaaaaaabf0e8 in get_thread_regcache (thread=0x0, fetch=fetch@entry=0) at ../../../repos/binutils-gdb/gdbserver/regcache.cc:31 #2 0x0000aaaaaaad785c in is_64bit_tdesc () at ../../../repos/binutils-gdb/gdbserver/linux-aarch64-low.cc:194 #3 0x0000aaaaaaad8a48 in aarch64_target::sw_breakpoint_from_kind (this=, kind=4, size=0xffffffffef04) at ../../../repos/binutils-gdb/gdbserver/linux-aarch64-low.cc:3226 #4 0x0000aaaaaaabe220 in bp_size (bp=0xaaaaaab6f3d0) at ../../../repos/binutils-gdb/gdbserver/mem-break.cc:226 #5 check_mem_read (mem_addr=187649984471104, buf=buf@entry=0xaaaaaab625d0 "\006", mem_len=mem_len@entry=56) at ../../../repos/binutils-gdb/gdbserver/mem-break.cc:1862 #6 0x0000aaaaaaacc660 in read_inferior_memory (memaddr=, myaddr=0xaaaaaab625d0 "\006", len=56) at ../../../repos/binutils-gdb/gdbserver/target.cc:93 #7 0x0000aaaaaaac3d9c in gdb_read_memory (len=56, myaddr=0xaaaaaab625d0 "\006", memaddr=187649984471104) at ../../../repos/binutils-gdb/gdbserver/server.cc:1071 #8 gdb_read_memory (memaddr=187649984471104, myaddr=0xaaaaaab625d0 "\006", len=56) at ../../../repos/binutils-gdb/gdbserver/server.cc:1048 #9 0x0000aaaaaaac82a4 in process_serial_event () at ../../../repos/binutils-gdb/gdbserver/server.cc:4307 #10 handle_serial_event (err=, client_data=) at ../../../repos/binutils-gdb/gdbserver/server.cc:4520 #11 0x0000aaaaaaafbcd0 in gdb_wait_for_event (block=block@entry=1) at ../../../repos/binutils-gdb/gdbsupport/event-loop.cc:700 #12 0x0000aaaaaaafc0b0 in gdb_wait_for_event (block=1) at ../../../repos/binutils-gdb/gdbsupport/event-loop.cc:596 #13 gdb_do_one_event () at ../../../repos/binutils-gdb/gdbsupport/event-loop.cc:237 #14 0x0000aaaaaaacacb0 in start_event_loop () at ../../../repos/binutils-gdb/gdbserver/server.cc:3518 #15 captured_main (argc=4, argv=) at ../../../repos/binutils-gdb/gdbserver/server.cc:3998 #16 0x0000aaaaaaab66dc in main (argc=, argv=) at ../../../repos/binutils-gdb/gdbserver/server.cc:4084 -- This sequence of functions is invoked due to a series of conditions: 1 - The probe-based breakpoint mechanism failed (for some reason) so ... 2 - ... gdbserver has to know what type of architecture it is dealing with so it can pick the right breakpoint kind, so it wants to check if we have a 64-bit target 3 - To determine the size of a register, we need to fetch the register cache, and we do so through a thread point, which is now nullptr.