From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id cvTzGLylY2oDqysAWB0awg (envelope-from ) for ; Fri, 24 Jul 2026 13:49:48 -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=Fd424rX4; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 49D821E033; Fri, 24 Jul 2026 13:49:48 -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 591781E033 for ; Fri, 24 Jul 2026 13:49:46 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7BE984BA2E15 for ; Fri, 24 Jul 2026 17:49:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7BE984BA2E15 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=Fd424rX4 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 6332B4BA2E07 for ; Fri, 24 Jul 2026 17:49:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6332B4BA2E07 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 6332B4BA2E07 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=1784915361; cv=none; b=fNS2GRt/6BBOSX94tEeLHJFn03Fk/UyH6H2t4wj1dnyI9uknb7ki6YDMj5fWGg1tJP+o2UJPYyyyQzKtPaZczYzv2juhd29wJfwF8gt4yAcWZeHffzNEbzS6e2KiR6i6TfKnRVL5/89F1UnwTigSOlhPyfvcjQORrpUZf2dkkrI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784915361; c=relaxed/simple; bh=yZMv0Bn6fwvlZK5WdHCcH6zCer633nRWhLoqF98Cq2M=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=LMB8/1XHEz+lbPfD0FOceVBspV+0al9Ed/wQt2AsdhViDtvKsonTLD5MClL9S9oNd/bJs9BtbomgtdkrWP4LlZDMsh0B+i/kDw2kIDRS/h8HYcQgpCtD73KjDsjzXspnhCbwLEHzGzmaXG5oTg1nXzpH3teVp7IWqa+8cL8Sydo= 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=Fd424rX4 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6332B4BA2E07 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784915361; 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=qsOWvoYypnZoL9Jb47uPi8HrlMlEOw5L2oa6LryfIJo=; b=Fd424rX4VDMgLd+jIT4Jw9S4CUAQ8BhaenyUKoy2gmxdqwrd3pr6ZpUuJUlefZLZWKCZ2/ TOSmZpfeBWMrv7lvZHsqra/87srHpVmI5UlurPJFbF2ZeusAyh+eo8z8EqZ10I7IUwWKSg mlGjSZmBpdbMwByn6/BTNSuXr7Ht630= Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-372-KUAO5fThN1Kpq15L06FHyw-1; Fri, 24 Jul 2026 13:49:19 -0400 X-MC-Unique: KUAO5fThN1Kpq15L06FHyw-1 X-Mimecast-MFC-AGG-ID: KUAO5fThN1Kpq15L06FHyw_1784915359 Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-38e6d253330so786510a91.1 for ; Fri, 24 Jul 2026 10:49:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784915358; x=1785520158; 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=qsOWvoYypnZoL9Jb47uPi8HrlMlEOw5L2oa6LryfIJo=; b=nSrqqPYZI3n8IHo8nIAcUEp9Kp6pB42phWinC2o4h5/74y4ZqrOwxCdoZDrgCH8t/0 4QOpUfWdKVNp9EWnH1kqG+E3W+6j6Seb13AbeJOWp0dPTdLP2SLtfWiLlm+0Rw5AKSLA LloY9wrODGMDGz0k8A54GH+b5rTj+KPTd6HazqFi7xJp4NFI/xmkUdEUh1+4K8Rv1I+k KuQmjOEqXZNdqCK/DNyd2LEtOoizPMY+Q58tfTU+7T7GABOcLEXwD06aYz0cwMggyUc6 LnQuFNFhv0Kf/jYUYSAn0T5XbvDdqvcdfqvvMIMSM3rBkBU76ckU/jnK3WPa48gpZSBU 7Bcg== X-Forwarded-Encrypted: i=1; AHgh+RpBjxepVpsq8IvkyZ2yUGyf/Z4pNTpUrGLx2xjOmoz36jF+XoUc3YXQ+X7lJhsaD6pP0NVOQ6UtMH/x7Q==@sourceware.org X-Gm-Message-State: AOJu0YzeX0guxYW86wHK+s+iXYyEUc29YHf7TG/YycS8vt+knDq74XSj 9zbTgIycaD50w1TvmnEVmyHtNLBUOVzBqTXWEa3kryMLLFw0Nrxbns6ou2D79+VGWz2uA6Jc8X/ 6H5BZgEXTsz/XTVLHFGjJb8KYIRzTN0zBZ/w1VpBcPfbnVt/F4r/vMvO0RcxZuZCa6l6yTcE= X-Gm-Gg: AR+sD131ldKy3iIIGlTHXWE5r3vfkD5nd66ngXWAStSvR1oQLB99oBeRNZwpf0J4mbj efJG/k6iyHnjb5OHW+B/5MsElEb6GpxBgjTDeknpAjv5//lNXbhFZbUELMagA9T7UjFym9P0tH5 Q8iQ7hJ8ruD9HYEKBTckLTow4ZARWeKffuM2Tuh8hCd1RinOM62CB0lsRprgFK0lUOdNZiHYTKP k7FGjf8xqmoD938X8v5qW5LgQ8kI4tymCiiFneX7VIBZL/VzsiTQ0SR/hjMRobNZZJVF49arLHT 0trFxjctS7WYrBCDZSjDQmm1hnZutqexg30Pd3BEB3SYWluPcg9fA1vOh50K/rPJHCw5dotXGvt 6/fmywkU= X-Received: by 2002:a17:90b:2707:b0:38e:7297:a92e with SMTP id 98e67ed59e1d1-38f1f9e4a0fmr993776a91.9.1784915358392; Fri, 24 Jul 2026 10:49:18 -0700 (PDT) X-Received: by 2002:a17:90b:2707:b0:38e:7297:a92e with SMTP id 98e67ed59e1d1-38f1f9e4a0fmr993755a91.9.1784915357922; Fri, 24 Jul 2026 10:49:17 -0700 (PDT) Received: from [150.1.200.157] ([172.56.105.224]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38f03c20c06sm1915555a91.12.2026.07.24.10.49.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Jul 2026 10:49:17 -0700 (PDT) Message-ID: Date: Fri, 24 Jul 2026 10:49:16 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] [gdb/testsuite] Fix race in gdb.threads/leader-exit.exp To: Tom de Vries , gdb-patches@sourceware.org References: <20260723114042.703464-1-tdevries@suse.de> <20260723114042.703464-2-tdevries@suse.de> From: Keith Seitz In-Reply-To: <20260723114042.703464-2-tdevries@suse.de> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: haTt_2JIq3LTeO7yzSf_A-QA3M3Rf_-PMYI86BWao7g_1784915359 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed 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 Hi, On 7/23/26 4:40 AM, Tom de Vries wrote: > > The problem is that after the pthread_join is executed: > ... > i = pthread_join (main_thread, NULL); > ... > > sleep (10); /* break-here */ > ... > there's a race between: > - the breakpoint at break-here triggering, and > - the "Thread exited" message for the main thread being reported. While I cannot reproduce this on my local hardware, your analysis is sound. > Fix this by: > - adding a loop before the break location > - waiting in the loop until the "Thread exited" message is seen > - sending ^C to get a prompt > - setting a variable to exit the loop > > Likewise in gdb.threads/non-ldr-exc-2.exp. Sounds like a plan! > diff --git a/gdb/testsuite/gdb.threads/leader-exit.exp b/gdb/testsuite/gdb.threads/leader-exit.exp > index b5e6f558ac7..22f27d2d6e8 100644 > --- a/gdb/testsuite/gdb.threads/leader-exit.exp > +++ b/gdb/testsuite/gdb.threads/leader-exit.exp > @@ -30,6 +30,28 @@ if {![runto_main]} { > return > } > > +# Wait for the "Thread exited" message. > +set re_thread_exited {\[Thread [^\r\n]+ exited\]} > +set saw_thread_exited 0 > +gdb_test_multiple "continue" "continue to thread exited" { > + -re $re_thread_exited { > + set saw_thread_exited 1 > + # Get a prompt. > + send_gdb "\003" > + exp_continue > + } > + -re -wrap "" { > + pass $gdb_test_name > + } > +} > +gdb_assert {$saw_thread_exited} "thread exited" > +if {!$saw_thread_exited} { > + return > +} > + > +# Let the inferior to exit the wait_for_exit loop. This comment got a bit jumbled. Superfluous "to"? > +gdb_test_no_output "set var wait_for_exit = 0" > + > gdb_breakpoint [gdb_get_line_number "break-here"] > gdb_continue_to_breakpoint "break-here" ".* break-here .*" > > diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp > index ead262cc2b5..dfc34f42afe 100644 > --- a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp > +++ b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp > @@ -37,6 +37,28 @@ proc do_test { lock_sched nonstop } { > return -1 > } > > + # Wait for the "Thread exited" message. > + set re_thread_exited {\[Thread [^\r\n]+ exited\]} > + set saw_thread_exited 0 > + gdb_test_multiple "continue" "continue to thread exited" { > + -re $re_thread_exited { > + set saw_thread_exited 1 > + # Get a prompt. > + send_gdb "\003" > + exp_continue > + } > + -re -wrap "" { > + pass $gdb_test_name > + } > + } > + gdb_assert {$saw_thread_exited} "thread exited" > + if {!$saw_thread_exited} { > + return > + } > + > + # Let the inferior to exit the wait_for_exit loop. Same nit in this comment. Question: Since this test file now relies on sending the target an interrupt, does it also need the same "require" on gdb,nointerrupts that leader-exit.exp has? Reviewed-By: Keith Seitz Keith > + gdb_test_no_output "set var wait_for_exit = 0" > + > gdb_breakpoint [gdb_get_line_number "break-here"] > gdb_continue_to_breakpoint "break-here" ".* break-here .*" >