From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from conssluserg-02.nifty.com (conssluserg-02.nifty.com [210.131.2.81]) by sourceware.org (Postfix) with ESMTPS id E28623858C2C for ; Thu, 23 Dec 2021 09:25:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E28623858C2C Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=nifty.ne.jp Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=nifty.ne.jp Received: from Express5800-S70 (ae233132.dynamic.ppp.asahi-net.or.jp [14.3.233.132]) (authenticated) by conssluserg-02.nifty.com with ESMTP id 1BN9Odi1027265; Thu, 23 Dec 2021 18:24:40 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com 1BN9Odi1027265 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp; s=dec2015msa; t=1640251480; bh=vNdQu37N1IsQSltKbwMERm2q0wGF5TW1uGKlcD/z8XY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=D8nMsvfTai9H28VtDf8udYllQyBQs5fVNhVAVizLeGN9bZ3TgGr+zPt+mvoilAtDc roo9cJBoLpfQkEiR+4Sg/YCCc16SUF91924Fe0W2sG+63XPAV+KN/DV9QO8M14aBGZ UafRkM+GL7DMniTfY6BdhDupzNfA8gLbI4c7A8n6GSdjBX5s5Ct7+X/Wnfmot39/Hv xuCdiOXiS5AjfYHENt1sFjlyB/HRPRu3N1coBO289mXUocTg6SU4LQFuS8W/esAAUN v9X38SQvPkBrsraGApNB9aeIM2n2bvfFOMXGldKMlqabioh/muoy/9mfELD65+p4mz JOuxe6w+NQwDA== X-Nifty-SrcIP: [14.3.233.132] Date: Thu, 23 Dec 2021 18:24:40 +0900 From: Takashi Yano To: cygwin-developers@cygwin.com Cc: David McFarland Subject: Re: deadlock on console mutex in gdb Message-Id: <20211223182440.e37115a4493516aca7ed7873@nifty.ne.jp> In-Reply-To: References: <20211223054409.610242feb0e96199904b3c9e@nifty.ne.jp> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: cygwin-developers@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component developers mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Dec 2021 09:25:28 -0000 On Wed, 22 Dec 2021 18:17:20 -0400 David McFarland wrote: > ===== test.c > #include > #include > > void *thread(void* p) { > printf("thread %p\n", p); > return 0; > } > > int main() { > pthread_t ids[100]; > for (int i = 0; i < 100; ++i) { > pthread_create(&ids[i], 0, &thread, &ids[i]); > } > for (int i = 0; i < 100; ++i) { > pthread_join(ids[i], 0); > } > return 0; > } > ===== > > If I compile that with gcc and run it under gdb, it hangs almost > immediately. 5/5 attempts using a fresh cygwin with latest packages. Thanks for the test case. I could reproduce your problem. I looked into this problem and found the mechanism causing the issue. GDB inferior may be suspended while the inferior grabs mutex. When the inferior creates new thread, GDB receives CREATE_THREAD_DEBUG_EVENT and inferior is suspended even if the inferior is grabing the mutex. This causes deadlock in terminal I/O. I think there is no other way than not to wait mutex in the debugger process. If anyone have any other idea, please let me know. -- Takashi Yano