From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id sQbvGAZusWqM/i0AWB0awg (envelope-from ) for ; Mon, 21 Sep 2026 13:48:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1790012934; bh=5i/u99Qoz4ID1yEGhnvCXJmvBBLTRmbXjJukMt011fU=; h=Date:Subject:To:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=PbUiIqO4Qpi/y3kDKVbQCMu35PJcCWofEXbj1p/fFs1zpQ/Tg2DfLE2fdU1I9xknG Ol+R2pLPqzEuxkR0d+ojQyeO7ZiQFwG29UAHcxBejPgYVE3prj7IHfO/AGXFEmGj24 rAMlrP0kGqaUL1bB1xls9SbvP4r0jvm63sYA/c3M= Received: by simark.ca (Postfix, from userid 112) id 5B5AB1E051; Mon, 21 Sep 2026 13:48:54 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=N2j3UgAE; dkim-atps=neutral Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 6033D1E01F for ; Mon, 21 Sep 2026 13:48:53 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 89C814BA9010 for ; Mon, 21 Sep 2026 17:48:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 89C814BA9010 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=N2j3UgAE Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 944014BA7997 for ; Mon, 21 Sep 2026 17:46:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 944014BA7997 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 944014BA7997 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790012806; cv=none; b=pQ5mbBfGtXGC4BBVII5DkMQkcPtSeX7Xsxmhfa5IUscYn8/20+hQEiG011etEp8UM0wvN4oGiHqlsPxNeSopricIexZdXpygBkLtBDl9Xxfk6lpmvNuNhD0l/ZOZudtbTyKkTy7HmhnzNMLp+vh+zT/xJ665A++K+9CXTVhl4mo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790012806; c=relaxed/simple; bh=5i/u99Qoz4ID1yEGhnvCXJmvBBLTRmbXjJukMt011fU=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=WiDzzLqDPftC5RcX/YWiFHb2gW64m0IqHrsSVsxCa7kkOrJkKiTttxn9QnyZTI76LdUIv5ewEZaq78IfIZIL9vQr/b0mpSucZ72vy+1a5TM7m8x2k4x+7pbP/OBXB7NCp1R0scKFgUpACvTZGNR6vkOib6VA+rNUkQVmRZxwGA0= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=N2j3UgAE DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 944014BA7997 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1790012805; bh=5i/u99Qoz4ID1yEGhnvCXJmvBBLTRmbXjJukMt011fU=; h=Date:Subject:To:References:From:In-Reply-To:From; b=N2j3UgAEVc7pdHtwlWmtqpgkVEEbXZT7P7t+IqLf0rte5v2sJPOqPjDq6uYW6+a9L mSzDEVwuyO7t9/cIVqU8vmihUY6T33SXeMtlsDP6WBQi5f8LN3yu0k2bFXN8xPEsLQ XcuRVxj5r0TL9qddMUCBHda+XsAsNOxz8cU899BU= Received: by simark.ca (Postfix) id 032BE1E01F; Mon, 21 Sep 2026 13:46:44 -0400 (EDT) Message-ID: <0a491ae3-f893-4543-afd8-658f650bd042@simark.ca> Date: Mon, 21 Sep 2026 13:46:44 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Return lazy value from allocate_repeat_value To: Tom Tromey , gdb-patches@sourceware.org References: <20260921161632.1602438-1-tromey@adacore.com> Content-Language: fr From: Simon Marchi In-Reply-To: <20260921161632.1602438-1-tromey@adacore.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 On 9/21/26 12:16 PM, Tom Tromey wrote: > A user noticed that the "@" operator could cause a crash in gdb. The > bug here was that value::allocate_contents might limit the amount of > memory allocated for the contents, but value_repeat did not respect > this. > > This patch fixes the problem by having allocate_repeat_value return a > lazy value. This defers to the memory reading to the "usual" code > that does respect these limits. > > Regression tested on x86-64 Fedora 43. > > Note that the new test only reliably fails in an ASAN build. > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34132 > --- > gdb/testsuite/gdb.base/printcmds.exp | 9 +++++++++ > gdb/valops.c | 4 ---- > gdb/value.c | 2 +- > 3 files changed, 10 insertions(+), 5 deletions(-) > > diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp > index 12933d898ed..0600eaf2ab6 100644 > --- a/gdb/testsuite/gdb.base/printcmds.exp > +++ b/gdb/testsuite/gdb.base/printcmds.exp > @@ -717,6 +717,15 @@ proc test_artificial_arrays {} { > {p int1dim[0]@TWO@three} > gdb_test_escape_braces {p/x (short [])0x12345678} \ > " = ({0x1234, 0x5678}|{0x5678, 0x1234})" > + > + # A regression test for a buffer overflow. PR gdb/34132. > + gdb_test_no_output {set $ctable = (char *) ctable2} Just wondering, is the use of the convenience var necessary? > + gdb_test_no_output "set max-value-size 16" > + gdb_test_no_output "set print elements 10" > + gdb_test {print $ctable[0] @ 20} \ > + [quotemeta {$@DECIMAL = {97 'a', 88 'X' ...}}] > + gdb_test_no_output "set max-value-size 65536" > + gdb_test_no_output "set print elements 200" Can you do with max-value-size 16 -- with print elements 10 -- ... to avoid having to set and reset the settings? Other than that, LGTM. Approved-By: Simon Marchi Simon