From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id +8o2F8HX5GTb3wgAWB0awg (envelope-from ) for ; Tue, 22 Aug 2023 11:44:01 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=VipyI1Xx; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4B1921E0C2; Tue, 22 Aug 2023 11:44:01 -0400 (EDT) Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (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 373411E092 for ; Tue, 22 Aug 2023 11:43:59 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B0B153856973 for ; Tue, 22 Aug 2023 15:43:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B0B153856973 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1692719038; bh=XMTsWzk/A8xTtrxB5Ncd0nGhJzrBeto5jB+snEtCiiA=; h=Date:To:Cc:In-Reply-To:Subject:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=VipyI1XxYGBg6YL4aghc5j0DEonZscTqUgXm0O5QeAp9I7x4SdBB/e/f/2yzD74hD /Hjy/uHuvsZoiKUkASb3c5pTigcqw3D6Pq29siKUDRQBh+aUEEnusfhI47hpa+fGMD 3TaOT/WXGgTAer3xpiOrl+gUcgt4HkGlZBDa2ZFA= Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 61F2C3858D28 for ; Tue, 22 Aug 2023 15:43:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 61F2C3858D28 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qYTXd-0000jR-8g; Tue, 22 Aug 2023 11:43:37 -0400 Date: Tue, 22 Aug 2023 18:43:57 +0300 Message-Id: <83wmxnrsjm.fsf@gnu.org> To: Pedro Alves Cc: gdb-patches@sourceware.org In-Reply-To: <20230822151332.4010554-1-pedro@palves.net> (message from Pedro Alves on Tue, 22 Aug 2023 16:13:32 +0100) Subject: Re: [PATCH] Fix Windows sharing_input_terminal hang References: <20230822151332.4010554-1-pedro@palves.net> X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Eli Zaretskii via Gdb-patches Reply-To: Eli Zaretskii Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" > From: Pedro Alves > Date: Tue, 22 Aug 2023 16:13:32 +0100 > > After running a number of programs under Windows gdb and detaching > them, I typed run in gdb, and got a hang, here: > > (top-gdb) bt > #0 sharing_input_terminal (pid=4672) at /home/pedro/gdb/src/gdb/mingw-hdep.c:388 > #1 0x00007ff71a2d8678 in sharing_input_terminal (inf=0x23bf23dafb0) at /home/pedro/gdb/src/gdb/inflow.c:269 > #2 0x00007ff71a2d887b in child_terminal_save_inferior (self=0x23bf23de060) at /home/pedro/gdb/src/gdb/inflow.c:423 > #3 0x00007ff71a2c80c0 in inf_child_target::terminal_save_inferior (this=0x23bf23de060) at /home/pedro/gdb/src/gdb/inf-child.c:111 > #4 0x00007ff71a429c0f in target_terminal_is_ours_kind (desired_state=target_terminal_state::is_ours_for_output) at /home/pedro/gdb/src/gdb/target.c:1037 > #5 0x00007ff71a429e02 in target_terminal::ours_for_output () at /home/pedro/gdb/src/gdb/target.c:1094 > #6 0x00007ff71a2ccc8e in post_create_inferior (from_tty=0) at /home/pedro/gdb/src/gdb/infcmd.c:245 > #7 0x00007ff71a2cd431 in run_command_1 (args=0x0, from_tty=0, run_how=RUN_NORMAL) at /home/pedro/gdb/src/gdb/infcmd.c:502 > #8 0x00007ff71a2cd58b in run_command (args=0x0, from_tty=0) at /home/pedro/gdb/src/gdb/infcmd.c:527 > > The problem is that the loop around GetConsoleProcessList looped > forever, because there were exactly 10 processes to return. > GetConsoleProcessList's documentation says: > > If the buffer is too small to hold all the valid process identifiers, > the return value is the required number of array elements. The > function will have stored no identifiers in the buffer. In this > situation, use the return value to allocate a buffer that is large > enough to store the entire list and call the function again. > > In this case, the buffer wasn't too small, it was exactly the right > size, so we should have broken out of the loop. We didn't due to a > "<" check that should have been "<=". Such a lucky hang... ;-) > That is fixed by this patch. Thanks, LGTM. Reviewed-By: Eli Zaretskii