From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id LGY1BeSJtWoLiz4AWB0awg (envelope-from ) for ; Thu, 24 Sep 2026 16:36:52 -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=HEC6RJ1r; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 006011E01F; Thu, 24 Sep 2026 16:36:51 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.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 autolearn=ham autolearn_force=no version=4.0.1 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 1D5B21E01F for ; Thu, 24 Sep 2026 16:36:51 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E4C144BB3BE6 for ; Thu, 24 Sep 2026 20:36:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E4C144BB3BE6 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=HEC6RJ1r 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 30B364BB3BCF for ; Thu, 24 Sep 2026 20:36:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 30B364BB3BCF 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 30B364BB3BCF 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=1790282184; cv=none; b=P066Lht+Kc5GCdTVyVXRFb+2rQ0puHU6OOQZU3/GbkTIME1DpEahYPoxtmuqJse3BCEr/u1PxfPkbdpTnFQKtclZ9t10G9gEtnqQIx8M7HwLaS7nQFNItJXkcdmy4ED5MBhdy6Q2HfVUBUeQILp/EwVuJO17x0hCWfI7o+byAWs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790282184; c=relaxed/simple; bh=MGc7YqxUz/Xp720Wi5LI6bdLrN/ksp7AtPn90VecsjM=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=uzcvut0E4ulrNe9cwdvV+6rb9VVIpe8BcHn+tUgPBrsSfB3+FtPcj2u4dmblmHIcCfyKblG7j7FSimg05e0xYLqhkJX7/aAHIQFTL42IA3PCgcH1x1MYRuYZTl0wM7pIZgcqi5ec9YpBwTiXCQM4WNuvik9NMcDaP8Rv8gDcAaY= 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=HEC6RJ1r DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 30B364BB3BCF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790282183; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g14HVm1K21CtMYKeLDWQRkRQLHCg/NOKOTw4/hMF+p8=; b=HEC6RJ1rLYKj7LZN/KlKFzpx4ZGWK+cbz5919qcge2gtnJfTG14R3n9h6TEW2OQwa0rwX/ gZ45iYPjX1G/PYkvC3S6iIpQaUUdexmEyoq9iXyCIO7DIUNKkm/igw+prts/smlbKxlmbw kNIpyv8ALIPVTKyIuRvf54h1w0oa+4M= Received: from mail-dy1-f198.google.com (mail-dy1-f198.google.com [74.125.82.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-652-Bf3jFma8Ph-DaEjepmpEIw-1; Thu, 24 Sep 2026 16:36:22 -0400 X-MC-Unique: Bf3jFma8Ph-DaEjepmpEIw-1 X-Mimecast-MFC-AGG-ID: Bf3jFma8Ph-DaEjepmpEIw_1790282181 Received: by mail-dy1-f198.google.com with SMTP id 5a478bee46e88-33baaba6371so554570eec.1 for ; Thu, 24 Sep 2026 13:36:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790282181; x=1790886981; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=g14HVm1K21CtMYKeLDWQRkRQLHCg/NOKOTw4/hMF+p8=; b=dNUHkvcEdYR1mh712zoChCnMhbNOOvsKPfIiSBMlK3+fu6d562LXZ5mKqpBVFr8Xk7 TBTSWsxwu34ZIESuu54Q3d4pgC24q/4oMsdGAIHmnDg83bIyadPL8GOaAWKlo2+AqHYh ly81fSEipkqGFlPd1HJiLOUmzBu2cQWnXrif50JSAVF/eeCCi8DRF+Hd2/6uV1HStrpc +F9+DFLPynQKtwayIswpK0ck+vhbDv7LsEMzOfTmg1z/bQYRdzYU2ZKTQZoJcaShgVaX ti7myMQEyP2SXV4eiod+5AoQBl10dUuSmyMJJZzSEaMF83cd0kGw15tv1ttNmCS6zQwQ A96g== X-Forwarded-Encrypted: i=1; AKwUvBxRLYtgaNbfIGIZ1wW/cmxUnLlfdbHlPdKiMeR9S4360V+cj7oc711BBYJIloEXcAWhmIx+7XqqZbcsXA==@sourceware.org X-Gm-Message-State: AFuF++nlQ5cg8aDqgeHP8160EgHuIAAZXDD3juzMTcjbgLdhbKlawnks rNe4WcvWCJsQr1jr6Bz2Uog/i5rvG1OYkqCjAoGAPGiz4Q2rtxiSxumz7IF6J/wZRGjsEC0CCAd nKctq5Z2Dgu0Xxne6jiDP9tfXjyEAGVq6pdsDpeXckTJ5QUKJJ8qHtS9iOcJdz9YgRXcKjng= X-Gm-Gg: AYBFou1lr4CzNuxOFGkdM/Exf8lCm8etZpjPFX/pFsgor6Awaj5IpRIoVhiMSI4wbtb vEq6uLz3lFSt6RkddSMH+hXZzrkqTo3lEXz7QaUx0N207M8V8/yrYbhHe8uTIui9h4MFsevn4Mu FwcU39EwChYvalvCpHI1s/Gp9pk5ADKJINhOm7lmUDgFpTTYZVNzqYCRHia5ZNgtUJcsOigYTHW 2vWlr6/o33MoXT03s3ZIFqxOr4Y6VZCaX74rI0JhO2GLTrmP1iIfQTAkL1nD+o5ivIkk42ygNTp hcwFZnPaYZrobtQfdCCxCTuZFCCV/DnrU7/5oWvc1eB+0MsB/9TnWWJULze1yirrurPPInzQ5Ns OBbVV7Fxw/fHSfP16Puj0iRtQFFiEM8pBx2SyLGZ91/an5Kf+ X-Received: by 2002:a05:7300:6026:b0:33c:e86:b2e6 with SMTP id 5a478bee46e88-340039aed4fmr3126629eec.34.1790282180771; Thu, 24 Sep 2026 13:36:20 -0700 (PDT) X-Received: by 2002:a05:7300:6026:b0:33c:e86:b2e6 with SMTP id 5a478bee46e88-340039aed4fmr3126614eec.34.1790282180147; Thu, 24 Sep 2026 13:36:20 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:993e:22e8:4ed1:527a:55c0? ([2804:14d:8084:993e:22e8:4ed1:527a:55c0]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3414485a9cdsm920476eec.16.2026.09.24.13.36.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Sep 2026 13:36:19 -0700 (PDT) Message-ID: Date: Thu, 24 Sep 2026 17:36:16 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Add QUIT to inner loop in value_print_array_elements To: Tom Tromey , gdb-patches@sourceware.org References: <20260922201202.2189948-1-tromey@adacore.com> From: Guinevere Larsen In-Reply-To: <20260922201202.2189948-1-tromey@adacore.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: MZCB8E1kX1qaJ8sHFVvZKGBWOX1qBQRTgkmEHPm-IN4_1790282181 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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/22/26 5:12 PM, Tom Tromey wrote: > When printing an array, some work is done to detect repeated elements. > This work is not interruptible, and it is somewhat slow (see > PR exp/32681). > > This patch adds QUITs to the relevant spots. > > I am not sure there is a way to write a non-racy test for this. Hi Tom! The code change seems pretty obvious. I tried to give a test some thought, and based on how long it takes to print a 1M sized array, we might be able to add a wait for a second or two and attempt to send a Ctrl+C signal, and check for a timeout, I think. Without real testing (and using the code in the bugzilla example), I wonder if this is workable: gdb_test_no_output "set max-value-size unlimited" send_gdb "p *p\n" # make sure that we're in the code looking for repeats sleep 1 gdb_test_multiple "\003" "cancel printing" {   -ex -wrap "" {     pass $gdb_test_name   } } I think this may work. The main racy issue I can see would be false positive, where we send QUIT before reaching the problem code, which isn't as much of an issue as the false negatives I don't think. That said, I just tried applying this and running that test manually and it didn't quit, there's still a large uninterruptible pause going on, so I think you may have missed a spot? -- Cheers, Guinevere Larsen it/its she/her (deprecated) > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17613 > --- > gdb/ada-valprint.c | 2 ++ > gdb/f-valprint.c | 5 +++++ > gdb/valprint.c | 2 ++ > 3 files changed, 9 insertions(+) > > diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c > index d66f9f84d52..020478bdf40 100644 > --- a/gdb/ada-valprint.c > +++ b/gdb/ada-valprint.c > @@ -183,6 +183,8 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr, > bitsize, elttype); > while (1) > { > + QUIT; > + > /* Make sure to free any values in the inner loop. */ > scoped_value_mark free_values; > > diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c > index d0b2030554f..2b54c8bf1c0 100644 > --- a/gdb/f-valprint.c > +++ b/gdb/f-valprint.c > @@ -36,6 +36,7 @@ > #include "cli/cli-style.h" > #include "gdbarch.h" > #include "f-array-walker.h" > +#include "event-top.h" > > static void f77_get_dynamic_length_of_aggregate (struct type *); > > @@ -188,6 +189,8 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl > struct type *elt_type, LONGEST elt_off, > LONGEST index, bool last_p) > { > + QUIT; > + > size_t dim_indx = m_dimension - 1; > struct type *elt_type_prev = m_elt_type_prev; > LONGEST elt_off_prev = m_elt_off_prev; > @@ -262,6 +265,8 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl > LONGEST elt_off_prev = m_elt_off_prev; > bool repeated = false; > > + QUIT; > + > if (m_options.repeat_count_threshold < UINT_MAX > && elt_type_prev != nullptr) > { > diff --git a/gdb/valprint.c b/gdb/valprint.c > index 83a442dcef5..7e41943f66f 100644 > --- a/gdb/valprint.c > +++ b/gdb/valprint.c > @@ -2038,6 +2038,8 @@ value_print_array_elements (struct value *val, struct ui_file *stream, > > while (rep1 < len) > { > + QUIT; > + > /* When printing large arrays this spot is called frequently, so > clean up temporary values asap to prevent allocating a large > amount of them. */ > > base-commit: 123e4a5eab2db300b44288dcc1a29c903f9622f9