From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by sourceware.org (Postfix) with ESMTPS id 83F283857433 for ; Wed, 4 May 2022 09:45:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 83F283857433 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f45.google.com with SMTP id q20so526940wmq.1 for ; Wed, 04 May 2022 02:45:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=igrfavrRAlUr/Bw7YxTCAnalt+WA6Eyck9MHjOLkaAg=; b=PjHhR/F8a7cDPpQob/p4br1149zL6JQJnA+OnpxQ5+XerkxK2LM7hpt5rFmpdg5H6r BQ/NROj7hpORfzDtIxFa9raq77Qwn7YySNAaJfhsvSqf4g0Ipj396R2mDndu3ws6lX4D FnLIF2vJchTbakzWP5Ab7hkqUnfkMqrZARFKV9xU4GORjIvsBq9Vk7OWEAl36cVZObbx f1Oz1culFXgjVm9M0O7cbmCLTvZe3jg33h5q0+FOvvIuSh7bW8WPvmbaMjAuS/nYxZ94 XLxfvXuJxgpitcvkMYEAKp4AKeW2rZvjCyebTArT4kD3SayjKR/G59tqZBhahBS2jxdK +AAQ== X-Gm-Message-State: AOAM53269KsrZw0fKjJbfRDXejb1kIMzWrdTKDHRqm6FoTU2YKl5axm+ PX/nPiY8ZI6pNy8+JrWuI7z0BdRMMeE= X-Google-Smtp-Source: ABdhPJzF615LlFNUzEweRLeHodvPCe8TKj69poXNrvlf8B1ByrZh+L+sRtA5l34fT2YvMbHM9pCFCA== X-Received: by 2002:a1c:4e0b:0:b0:393:fd8f:e340 with SMTP id g11-20020a1c4e0b000000b00393fd8fe340mr6828737wmh.136.1651657549263; Wed, 04 May 2022 02:45:49 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id w3-20020adfbac3000000b0020c5253d928sm11076502wrg.116.2022.05.04.02.45.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 May 2022 02:45:48 -0700 (PDT) Message-ID: <51c7d9e9-7d84-f826-be2d-be559847da9b@palves.net> Date: Wed, 4 May 2022 10:45:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH 0/2] Fix gdbserver/linux memory access regression Content-Language: en-US To: Luis Machado , 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> From: Pedro Alves In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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:45:52 -0000 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.