From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dmta0015.nifty.com (mta-snd00003.nifty.com [106.153.226.35]) by sourceware.org (Postfix) with ESMTPS id 33BB33858C33 for ; Sun, 21 Jan 2024 11:10:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 33BB33858C33 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 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 33BB33858C33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=106.153.226.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705835457; cv=none; b=K79aVjsTjQ2ifEfJaBrOGBXbQyujokzkn8ohCjFY1qoOaI86iWB7F+zHCH+KPUxudT/tUCPAF+/F8jgLGVYbxrnAmlyLiN8+A5DOHuU3MhDs1TuanL1eq37G91N7kXRbwQ21eaGFD+TSVjZzJ8m8ITUf67yuD2Gf1lkx1Asp/Hs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705835457; c=relaxed/simple; bh=RuAYIrUV+WY+hphJLEVtDeRWW2O9yM0Z0AYFg+bKWog=; h=Date:From:To:Subject:Message-Id:Mime-Version; b=FOOyhCyIYOQe7Sa8rJu8I9/9yRwq7qSIYfQLayQhIVhI3mgktQb+/urHeXh3RTL1zdxmxOYlYWA1oBCgC5PFrczMyuCMT8Ik06BtmAE1C+HwPsHevGri/r5IIapSiZX9sXEWu9uUMQEpYikXTKSQs9zN+DXTk/JBCiGQquoJHDc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from HP-Z230 by dmta0015.nifty.com with ESMTP id <20240121111052004.TUDX.14278.HP-Z230@nifty.com> for ; Sun, 21 Jan 2024 20:10:52 +0900 Date: Sun, 21 Jan 2024 20:10:51 +0900 From: Takashi Yano To: cygwin@cygwin.com Subject: Re: Possiblly bug of cygwin1.dll Message-Id: <20240121201051.795a4405576a97ab8729e273@nifty.ne.jp> In-Reply-To: <20240120212427.1e69fd3655ece73ecd508def@nifty.ne.jp> References: <20240119224436.876a055f356f7c6796bc725b@nifty.ne.jp> <20240120131825.4157c259fe058155137d6fe0@nifty.ne.jp> <20240120141349.cde31e62177a0405b0ee9934@nifty.ne.jp> <87v87ov03x.fsf@Gerda.invalid> <20240120212427.1e69fd3655ece73ecd508def@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=-3.9 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Corinna, On Sat, 20 Jan 2024 21:24:27 +0900 Takashi Yano wrote: > On Sat, 20 Jan 2024 10:13:22 +0100 > ASSI wrote: > > Takashi Yano via Cygwin writes: > > > I might find the culprit in gcc's libstdc++ code such as: > > > libstdc++-v3/include/ext/concurrentce.h: > > > class __mutex > > > { > > > private: > > > #if __GTHREADS && defined __GTHREAD_MUTEX_INIT > > > __gthread_mutex_t _M_mutex = __GTHREAD_MUTEX_INIT; > > > #else > > > __gthread_mutex_t _M_mutex; > > > #endif > > > > > > __GTHREAD_MUTEX_INIT here is PTHREAD_MUTEX_INITIALIZER and > > > __gthread_mutex_t is pthread_mutex_t. > > > > > > I think this code vaiolates the POSIX statement. > > > > So what happens if you undefine __GTHREAD_MUTEX_INIT? > > I have tried. The test case: > #include > int main() > { > for (;;) { > std::mutex *m = new std::mutex; > m->lock(); > m->unlock(); > delete m; > } > return 0; > } > gets working fine. However, this test case: > #include > int func() { return 0; } > int main() > { > for (;;) { > std::future f = std::async(std::launch::async, func); > f.get(); > } > return 0; > } > still has the problem. > > pthread_mutex_t might be initialized also at another place... I found the cause. In pthread.h of cygwin, PTHREAD_ONCE_INIT is defined as: #define PTHREAD_ONCE_INIT { PTHREAD_MUTEX_INITIALIZER, 0 } however, libstdc++ initializes non-static pthread_once_t using this macro. I cannot find the POSIX statement that only static pthread_once_t can be initialized using PTHREAD_ONCE_INIT. If I do not overlook something, this is the problem of cygwin side, isn't it? -- Takashi Yano