X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF7AB385842D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1705724366; bh=sqfEcemKjeWr9kAgewGPYv385sVI+sr8y+kI8v1bT5E=; h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=I8hhBMWnLOPgMvWDccTaE8m//w8X+6vUdsrxIYEKaDKv10yel3jxI1GsMiRzcY0dU B7oSeeR9fc26WaaO77MQJ0WZsZ4n9u3i+mvZLmSHkcJqzuqqDMLOPORUQYgGGUfW3I 6O3+rf/w4VnF8L5zbhBeqfdj1Xy7eVoLniDohGxk= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 94C743858D3C ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 94C743858D3C ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705724312; cv=none; b=UaL06qdjUI0qLdwGe8DCi3vhXhlz9nlaHdM94ZlOS5tLyVipV6oRNXSOLgrs/3gAzs+3on8F3XtpRNFfaTIxt/Kv0vBUtje0Q9CEgiepW1DXDG0tgssmIsjrBZyJv8h8dU5fw5bncjAx41xouQs0KC996hQKSV63Zra2YTR4tdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705724312; c=relaxed/simple; bh=XkHisRUs5alVbvH+pRAFuLPz6dfo2+hQ0girvo1hxsU=; h=Date:From:To:Subject:Message-Id:Mime-Version; b=ZmWGRT9OqlYpvMjioK4tKBehfqgxA6mFVIPX0i6XQM0vraMjBCLqEqrkHvJCeeOeVIV1dyGyBoqBhpZUfIGMpxqoSJqJthNPOM0hihWZ1sb6/zEfgs1+Ifs9D/DeW3/KbbIE05rjVy0WCg1JHqCJB/AXFmiYiHSZMKqbi2yw8ZU= ARC-Authentication-Results: i=1; server2.sourceware.org Date: Sat, 20 Jan 2024 13:18:25 +0900 To: cygwin AT cygwin DOT com Subject: Re: Possiblly bug of cygwin1.dll Message-Id: <20240120131825.4157c259fe058155137d6fe0@nifty.ne.jp> In-Reply-To: References: <20240119224436 DOT 876a055f356f7c6796bc725b AT nifty DOT ne DOT jp> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 X-Spam-Status: No, score=-5.1 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 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Takashi Yano via Cygwin Reply-To: Takashi Yano Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Hi Corinna, On Fri, 19 Jan 2024 15:28:40 +0100 Corinna Vinschen wrote: > On Jan 19 22:44, Takashi Yano via Cygwin wrote: > > Hi, > > > > I might find the bug of cygwin1.dll (including 3.4.x, 3.5.0 (TEST)). > > The following test case (c++ code) causes handle leak. > > > > This issue is reproducible with both g++ and clang++. > > However, it does not happen in Linux environment. > > So I guess this is the cygwin1.dlll bug. > > > > I looked into this problem a bit, and found number of event handle > > increases every loop. > > > > I doubt pthread_mutex_xxx functions. > > > > #include > > int func() { return 0; } > > int main() > > { > > for (;;) { > > std::future f = std::async(std::launch::async, func); > > f.get(); > > } > > return 0; > > } > > Can you create a plain C testcase from there? It's much easier to > debug. I could symplify the test case: #include int main() { for (;;) { std::mutex *m = new std::mutex; m->lock(); m->unlock(); delete m; } return 0; } And I tried to observe the pthread_mutex_xxx() call. Then found the test case does like: #include int main() { for (;;) { pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_lock(&m); pthread_mutex_unlock(&m); } return 0; } POSIX states pthread_mutex_t can be initialized with PTREAD_MUTEX_INITIALZER when it is STATICALLY allocated. In this case, m is not static. So it seems that this is a bug of libstdc++. However, the plain c code above works in Linux without problems even with non-static mutex m. I guess it is very difficult to make the plain c code above work in cygwin, because cygwin can not know when cygwin can discard the mutex resources... -- Takashi Yano -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple