From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id YD4pCHV6iGqJIjQAWB0awg (envelope-from ) for ; Fri, 21 Aug 2026 12:19:01 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=AjrROxqi; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 01D9B1E0A3; Fri, 21 Aug 2026 12:19:00 -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 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 E9A111E033 for ; Fri, 21 Aug 2026 12:18:59 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4B8E04BB1C23 for ; Fri, 21 Aug 2026 16:18:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B8E04BB1C23 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=AjrROxqi Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id A3EDC4BB1C0D for ; Fri, 21 Aug 2026 16:18:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A3EDC4BB1C0D Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A3EDC4BB1C0D Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::232 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787329115; cv=none; b=GaOHOqCErJK2gVt4DOFZObImw5pX/xUbKq9GS8r0Ww725/WD16WLQPis3GP0bUIi1ed5knmox5/msNtL8kDEPlcFeeRRefjsnFFsO0qltMS1Vn+rmIdkYdhEPhSE2WS+calQkzxC3UcnfNCRPm730bBsMrzj6WEO3mr0o/GAsek= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787329115; c=relaxed/simple; bh=8AvNzeph6MfYsIpAcRLtFn6AmWcXka2UqaXtUD9nNls=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=gxrpcq12z10N2xWdeoa/Oz4zqWTBa8wYlctul6XpDDxpkOwX9L5h0L56nsvg6mqR6EN3M9NSm3ycfny7po+UIVeZ/PYWeDM6l3JWJrmoHr8VfJTVpiLZQbr85z9NYXEA21mY0Nk+kFXZoSMOw0FNZEu+WQ0dnhW0IfxbnM4vBxg= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=AjrROxqi DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A3EDC4BB1C0D Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-39c8e65e3f5so11325951fa.0 for ; Fri, 21 Aug 2026 09:18:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1787329113; x=1787933913; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=j+XEwEmi8wDvhT9buHpLaL48L1UZaR9DK399E0pgA1A=; b=AjrROxqitggEo3lwqV80g3FNxhpKOWDvqk4qlmOXzzC1CkoN3qm2i/B9+GEcKWFxQ8 D4Y4zXGlCkrF6KK9dERsH3Mye850RBnwGc03FsSUBas1PEODUh1CLzjim8eK64w+bUqq sUT92XrbYyh7pdH94j2MbA8WjJXeceLhKtgOS7XKnRScvMfOTNcTRZ2E+nXrnBdXRhzA dIQDrBXLO27C8/6P/87GDUIk6uL5UzfUb53Tk+py9b4yE8iQajvq/BnU8a/8veGyFeBm hpw4Zfkguf7kJI/OLlTMwFDSCZncpN4yNRMdW/1YdgeqLuqFQ5k5W2n41BL/YPQbh3u0 hCUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787329113; x=1787933913; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=j+XEwEmi8wDvhT9buHpLaL48L1UZaR9DK399E0pgA1A=; b=Tc59OUXCXlPUWLRhvfDJAbKwZvFqLcjeELCo/jC0j0mwam2JBcVd0wh5lKql65eHEg OQk5rSbsETunIpolhRtujxL4euZxV+Ru7D+qOaDZeCiH7lefE79TA1tLxB5NOTIJRoX1 NepZX4Vx34p9EsRE6m9wtPj/C47lte6YFEsv7oaJ4hruxXnxGwO5etVLiuwkY3ENtgjW +1fDhA2r65/fRrivb6UQFV6i4uzrejdGoiR1qzuIfPxNhrsCp7AbVhXnhqCV9N+CkHnH z6K77g8+wICcbBuz+de0QkVS5hAZ3iQfte/v5tCpehTKvNraHBgZPdGF81tx5umsC5XJ BZDQ== X-Gm-Message-State: AFuF++nRXwKchyIVweCA+igc9Tp73oIrSSTk4Gu+yYi0ctfEcn9dEmvq 1uZmfeNqJvxpn2BBf1kCYZ94W3Kvl50NluCgN2OLxwdyFI9F24uRFxUs5PVw0JIU8iZNtMRkllr Le/M= X-Gm-Gg: AR+sD13qBtxyT8NUgUt79YxdiYEFM/ghvA53p8chLhcslxrQjsGz7Hb90x79W8c1qud cy/6y0rJ4vJGKiYvZOlgi6AhmWOmmrgauGeRqLEVEOYO//e+rblbzjjDTxeJAfJw3IB9glFfGa1 rQgkGQ12HT69IKT63Q4c292O23rL2kF+1uxfOHfg8f0ca2rOi2Vln9TCmaQH1Ayhxz8/ASjBpvq RbzKZM/6S2cDpSc5BShpW0WxPXFN3+mT1O4LuqiqbcPwC+BTvafEq4QCkVAOoNS/SN8iANPYJ2F HoUIB+VaBCaUBTQIMSaaNGAVEgGyWuPovyMfwb16FiWBAjFcUN6bLpy7veXqMRJSE32+HWWONz2 y4ByNMpLeGaaLHjSGBU5RebyFuYraqik+lZFyYrNvzbgGU5XQ3fcx9X4R52zDGT0hncMvh95qdQ 4PslGlqvu0eN3ghK93QgTTPvk1G/U+M4IQRprDT3yUvKzJaMB8fS0b08y+idlOfjCMBJqH6NDS/ MAW0w6bEPfsGP0m X-Received: by 2002:a2e:be10:0:b0:3a1:8dd6:aad9 with SMTP id 38308e7fff4ca-3a1aeba32d0mr19408581fa.2.1787329113414; Fri, 21 Aug 2026 09:18:33 -0700 (PDT) Received: from bapiya (97-122-117-2.hlrn.qwest.net. [97.122.117.2]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3a189d1b90esm23734391fa.18.2026.08.21.09.18.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2026 09:18:32 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Ignore the last EXIT_THREAD_DEBUG_EVENT on Windows Date: Fri, 21 Aug 2026 10:18:28 -0600 Message-ID: <20260821161828.1836622-1-tromey@adacore.com> X-Mailer: git-send-email 2.55.0 MIME-Version: 1.0 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 The Windows non-stop series caused some regressions in the internal AdaCore test suite. I filed this as PR tdep/34195. I finally found some time to look into the problem, and this patch is the result. The symptom of the problem is that some fairly ordinary tests -- like a test to simply run a do-nothing program to completion -- would fail because gdb would print "No unwaited-for children left." I bisected the problem to commit ae2f226d ("Windows gdb: Add non-stop support"). Instrumenting the test suite to enable logging showed something strange: in the failing case, we'd see and EXIT_THREAD_DEBUG_EVENT for each thread, but never an EXIT_PROCESS_DEBUG_EVENT. And, since gdb didn't see or handle an EXIT_PROCESS_DEBUG_EVENT, the process would remain live -- one of the internal AdaCore tests checks this (via some "ps" equivalent), causing a separate failure. After a lot of experimentation I came up with this patch. It changes gdb to ignore the final EXIT_THREAD_DEBUG_EVENT, waiting instead for an EXIT_PROCESS_DEBUG_EVENT to do the cleanup. This fixed the regressions in my testing. I still don't fully understand this bug, though: 1. It only happened under load, I was never able to reproduce it by running a single test case. It's worth noting, though, that I ran the test suite against gdb 17 on the same Windows instance, and that always worked flawlessly -- so it seems like it's definitely a gdb bug and not an OS bug. 2. Windows supposedly shouldn't even issue an EXIT_THREAD_DEBUG_EVENT for the final thread, only EXIT_PROCESS_DEBUG_EVENT. At least IIUC. So, the fact that we're even seeing this seems mysterious. However it's worth noting that the patch only affects this case, so if Windows does not emit that final thread-exit event, everything should still work fine. I've marked this bug as blocking gdb 18 because it is a regression. If approved I plan to apply the patch to that branch as well. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34195 --- gdb/windows-nat.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index def8fa606f4..0e958ea8186 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1570,6 +1570,32 @@ windows_nat_target::get_windows_debug_event case EXIT_THREAD_DEBUG_EVENT: { + /* If we see the last thread-exited event, and then we go + ahead and delete the thread, this might cause gdb to stop + issuing calls to ContinueDebugEvent. See PR dept/34195. + This has two bad effects. + + First, the EXIT_PROCESS_DEBUG_EVENT is never handled, so + the process doesn't truly exit -- something that can be + detected by examining the running processes on the system + (i.e., using the equivalent of "ps"). + + Second, gdb will tell the user "No unwaited-for children + left", which is not really something users do or should + understand. + + This stanza works around this problem: we treat the exit of + the last remaining thread as a spurious event, causing gdb + to call ContinueDebugEvent; the thread exit is then handled + by the EXIT_PROCESS_DEBUG_EVENT. */ + inferior *inf = find_inferior_pid (this, current_event->dwProcessId); + auto rng = inf->non_exited_threads (); + if (std::distance (rng.begin (), rng.end ()) == 1) + { + ourstatus->set_spurious (); + return null_ptid; + } + ourstatus->set_thread_exited (current_event->u.ExitThread.dwExitCode); thread_id = current_event->dwThreadId; base-commit: a3a56294a7c5e5898309c04cc3b1e490cca76ef7 -- 2.55.0