From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id +fqEAD29o2qKRD8AWB0awg (envelope-from ) for ; Fri, 11 Sep 2026 04:35:09 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=d1yfPcPn; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id F0FAF1E091; Fri, 11 Sep 2026 04:35:08 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 75B951E091 for ; Fri, 11 Sep 2026 04:35:08 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9BAE648FBC90 for ; Fri, 11 Sep 2026 08:35:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9BAE648FBC90 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=d1yfPcPn Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 3C0564A9E045 for ; Fri, 11 Sep 2026 08:34:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3C0564A9E045 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3C0564A9E045 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789115679; cv=none; b=bNaDd78wnajiPdekaLDBqyu/uYQ2nK4s2hPQfqLofnIPsbakU1puci8dfc1rJ5VU1pps7G4iWtl3kD+OzPEaJ1uQZOGpMmi6RJWLRZ5KG0QXL8tbTbAx0Lc4Pq2HW33yJuQ9kpA2swcCGR6W8eMnCMHy1nOJGz1jXWrTBRpTmpI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789115679; c=relaxed/simple; bh=JEQF0Kl1ROAc2l+91OsN51z+lsvoMe3+e39FRvRUBBg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=cP6/kudilK3xVc9a8z5N13e8d8Eng5Op/YIKaGRIQiVyPiI/E/68UfxWjj4DlAFkL0mWlaTJOMs2se25afHdq62waRRm7NkM/9vLQ9sExXLDL0ZRmD9Gma9mFrp/6TYGq8kEalc1kNlxjTcEEkY/pjC8TxUQUIpMf+84TYGfJes= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=d1yfPcPn DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C0564A9E045 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789115678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2eghCUMwM11QTlQZBPT2Gx/v/7CPpXfU1BeGxcgjERA=; b=d1yfPcPn6hrKyHgXgSs0l9jlDskFQ3epemSLNeVh5FsPUTNc/9t3mpoMnazIiAfKUdb+/7 fcQ2ig9oWDsJcfROobLP/vFdirym4C8n0mMBwrirl+w9sqeFVux4IL3SGkmv+FOydqiKlu sNjmtEK5cCAtNFpNo9xk2Sym0qMfq+M= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-274-RA3a1cheMxCJVMpTRAHkPw-1; Fri, 11 Sep 2026 04:34:35 -0400 X-MC-Unique: RA3a1cheMxCJVMpTRAHkPw-1 X-Mimecast-MFC-AGG-ID: RA3a1cheMxCJVMpTRAHkPw_1789115674 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-48597bbd963so432297f8f.2 for ; Fri, 11 Sep 2026 01:34:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789115674; x=1789720474; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=2eghCUMwM11QTlQZBPT2Gx/v/7CPpXfU1BeGxcgjERA=; b=hQRaDtnUq8UBujqTw38Eo1yrdGERnmSvh9LZT7fDDn/aQGW4xETwvyMmlZbzQzeTpf VP+xBAXdpPmybbcXw/K4PPtpdcT1Vhz2Ziss5toM09duRuZDt0ZWgPrjND7jiAV2m9s/ 2S+zP8Ap+9fYsnz+pmOyv3mJvLB6G7BQECsdxQiW0etcMeUwKcxmX60DpHuf19+1LImT qoSFfibLq/A6L3mZiTc3CHEuA0ae+WOlzD+Blw670z2YV6Zx0TbI53xvNhMA2Mbk+bgT JTzA6J3rLQW/GW1cYCUj5CdfpJb7pWduC4cwrAXrXSdMbXaNOHPL/Wxr2zL/uvru92IX wkXw== X-Forwarded-Encrypted: i=1; AKwUvByK5Rupgw+J/r7b+2Q58BjPjecNBCWLIX1u1ISz1sz1a9ZQ/PJBjJCSUzxv+Lb/4J3bdx2Uk9MK9YaAoQ==@sourceware.org X-Gm-Message-State: AFuF++lOhfLJFtsxkofZp0AC2hMwQ9U+NSl84rhXalMYnu3WRZ+Iop9k s1YGBZA5ttaL6Em6FnU3z+CjeO1Uo1XHHxH/FDanZA4QW/bpFWSajXMTBOLfr4E4KcZPsde8WsH uu0UbYxo7d1WQUl0hFz2hUby+1+KBnv5cb+qcbFzxx9fqUJaQoo1N8W/7efhU5qM= X-Gm-Gg: AYBFou0GEMmbphHZzYNBYtk9SuJ3i6B6axxD6aAf3fb+nVyM6lh4Z+/JMlKcY4YKKk8 yscG2gowasa3496trFC3VLWWT/pRwr1RTfPslwmNBicWx2KL6RNHdR3Hi3KFXNjlzZBkOnD/TaE ZZrwCy6yWGD2470qiigjcTcBMpsQuS4b+pxS/4ES6zaglRFD7H6oNeKVzRBHb8N+XyFUAmeSygR x4FZljYuoEw7fRVT42w8aIFtG/o+Um5KVrRq58mWhYY1VXf3c7F1lG3Ip3fpNgXamkhgQwIziFX apnB/SIsSgKo+SYQqkzTf8WSQJVV926H/uu1M0ADQLSQCvolAUYTHX7/+y68O1GzLBKK9qy+6Ut KtzCL2QxEd4xOaHXk X-Received: by 2002:a5d:5d05:0:b0:486:e5f7:89c5 with SMTP id ffacd0b85a97d-486eb1d85b8mr6734125f8f.1.1789115674316; Fri, 11 Sep 2026 01:34:34 -0700 (PDT) X-Received: by 2002:a5d:5d05:0:b0:486:e5f7:89c5 with SMTP id ffacd0b85a97d-486eb1d85b8mr6734061f8f.1.1789115673872; Fri, 11 Sep 2026 01:34:33 -0700 (PDT) Received: from localhost (59.6.93.209.dyn.plus.net. [209.93.6.59]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb33e020sm4472139f8f.18.2026.09.11.01.34.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 01:34:33 -0700 (PDT) From: Andrew Burgess To: Matthieu Longo , gdb-patches@sourceware.org Cc: Simon Marchi , Thiago Jung Bauermann , Luis Machado , Luis Machado , Christina Joos , Kevin Buettner , Matthieu Longo Subject: Re: [PATCH v2 5/6] gdb/linux-tdep: migrate linux_find_memory_regions_full to file_reader_t In-Reply-To: <20260825100912.514232-6-matthieu.longo@arm.com> References: <20260825100912.514232-1-matthieu.longo@arm.com> <20260825100912.514232-6-matthieu.longo@arm.com> Date: Fri, 11 Sep 2026 09:34:32 +0100 Message-ID: <875x0cdw4n.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: LlOaJERARhX65KJfvpmrwi5e3_SXnesGufTnHOS_X7w_1789115674 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Matthieu Longo writes: > The previous implementation of linux_find_memory_regions_full could > still return success even when none of the /proc/PID/[s]maps files > existed, or all reads returned 0 bytes (this last case can happen on > Linux when the thread-group leader has exited). > As a result, the function could incorrectly succeed, allowing core > dump generation via the gcore command. > This logical defect was allowing, by chance, the function to return > success and hence, allowing fortuitously the coredump generation via > gcore command (see gcore-stale-thread test for more details). > > A previous patch in this patch series fixed this issue by using the > first LWP ID of the current inferior instead of relying on the PID. > This patch adapts the code to use file_reader_t and makes the function > return an error if reading any of the procfs files fails. This commit message seems out of date. As far as I can tell the issue you are describing here isn't fixed yet. Further, I took a look at gdb.threads/gcore-stale-thread.exp and couldn't find any text talking about this issue, so saying "see gcore-stale-thread test for more details" isn't super helpful. It doesn't sound like this patch was actually aiming to fix the bug you described anyway, just to convert to the file_reader_t class, so honestly, I'd just drop all discussion of the previously fixed bug. But if this patch is fixing the bug then I'd expect either a new test to be added, or if gcore-stale-thread.exp does hit this bug, I would have expected the test to be updated now that the bug is fixed. Thanks, Andrew > > Reviewed-By: Thiago Jung Bauermann > --- > gdb/linux-tdep.c | 22 ++++++++++------------ > 1 file changed, 10 insertions(+), 12 deletions(-) > > diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c > index e2c5b2d8815..2833d8a4bb6 100644 > --- a/gdb/linux-tdep.c > +++ b/gdb/linux-tdep.c > @@ -1828,24 +1828,22 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch, > } > } > > - std::string maps_filename = string_printf ("/proc/%ld/smaps", ptid.lwp ()); > - > - gdb::unique_xmalloc_ptr data > - = target_fileio_read_stralloc (NULL, maps_filename.c_str ()); > + std::vector smaps; > > - if (data == NULL) > + file_reader_t smaps_freader > + (string_printf ("/proc/%ld/smaps", ptid.lwp ())); > + if (smaps_freader) > + smaps = parse_smaps_data (smaps_freader); > + else > { > /* Older Linux kernels did not support /proc/PID/smaps. */ > - maps_filename = string_printf ("/proc/%ld/maps", ptid.lwp ()); > - data = target_fileio_read_stralloc (NULL, maps_filename.c_str ()); > - > - if (data == nullptr) > + file_reader_t maps_freader > + (string_printf ("/proc/%ld/maps", ptid.lwp ())); > + if (!maps_freader) > return false; > + smaps = parse_smaps_data (maps_freader); > } > > - /* Parse the contents of smaps into a vector. */ > - std::vector smaps = parse_smaps_data (data.get (), maps_filename); > - > for (const smaps_data &map: smaps) > { > /* Invoke the callback function to create the corefile segment. */ > -- > 2.55.0