Re: std::mutex bug: Windows handle growth

Noel Grandin via Cygwin <[email protected]>
Newsgroups gmane.os.cygwin
Message-ID <[email protected]>
Hi

Hazarding a guess here:

On 3/16/2026 11:39 PM, Frank Eskesen via Cygwin wrote:
> I've run into a problem that occurs on Cygwin that doesn't occur on Linux
> systems: When a std::mutex is used, it doesn't clean up a Windows handle that
> it uses. This sample program demonstrates the problem, failing in under 60
This code looks suspicious:

     pthread_mutex::destroy ()
     {
       if (condwaits || trylock ())
         // Do not destroy a condwaited or locked mutex
         return EBUSY;

I think it should be

       if (condwaits || !trylock ())

Regards, Noel Grandin

-- 
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.