delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2026/09/22/00:57:47

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 68M4vkEL2651504
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 68M4vkEL2651504
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=QNkcJQIH
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 54C784BAE7E9
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1790053049;
bh=OHxZHsca8VtPdmeeOU5Pj/EVG+AQ1iHZR9kQlzuet6s=;
h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=QNkcJQIH42xE8dflK651RJ2O3JINb8mCajJJ6414HmsEkelCcmF3Wzhfl5P7J2xku
mLLBlt2uamPyTyWYZPuyunOnQw8X7o09o0sDU5GN05Gs1gkcClHX/msMVGGjPws2IA
C/j32qG0IL4DawPJg2eOi9cC8if2TI+a7LJfKgb8=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 594044BA9014
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 594044BA9014
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790053003; cv=none;
b=uqDM4Vjt1OtXrZMQGQXQkCgxF1ERRTfbwQ0NPpJwnsRqvCmIB73e7ExODvZ4P/tQPS564yndLTfTwpjcKYKMN/slkFDTnbSWzqygjgwFrkl9KEDznj1o65xrvGcQ/q6M5CSXoo4b9Tm3HTv+7luE1CJP3jqypkt2mE228pKze6E=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1790053003; c=relaxed/simple;
bh=mOdIivDC3vqNX6B/9I7oLE6dF0A4AzHgxsT6AWRglPg=;
h=Message-ID:Date:MIME-Version:To:From:Subject;
b=jCTg7bYO4nM/e7G7kB1Un4ptfJwchqd8S1D6b56zI60s31gSWco0Xfst1ubaeHUHk/TbsxpQIh+ndZuBn34QjitIaEuT1wsCcgqx3Jqpf5l8NuX3F+iMmPTt8YhcgWdSL3cKqKVFwwZ8HNlqGOdh+h6IwHU60UuT/9evida9MiI=
ARC-Authentication-Results: i=1; sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 594044BA9014
Message-ID: <251f3669-7a74-484b-9aa1-96995e042e71@maxrnd.com>
Date: Mon, 21 Sep 2026 21:56:34 -0700
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
To: The Cygwin Mailing List <cygwin AT cygwin DOT com>
Subject: Re: std::mutex bug: Windows handle growth
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Mark Geisert via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Mark Geisert <mark AT maxrnd DOT com>
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 68M4vkEL2651504

Hello kikairoya,

> Hi,
> 
> std::shared_mutex (actually, __shared_mutex_pthread) appears to need a similar fix.
> Could you take a look?
> 
> 
> 2026年3月18日 4:09:53 (+09:00) で、Corinna Vinschen via Cygwin さんが書きました:
>> 
>> The actual problem here is the `#ifdef __GTHREAD_MUTEX_INIT'.
>> 
>> __GTHREAD_MUTEX_INIT translates into PTHREAD_MUTEX_INIT.  If this is
>> defined, you will notice the there's *no* destructor defined for class
>> __mutex_base.  Apparently the assumption is made that the underlying
>> pthread_mutex_t type is a trivial type which doesn't need a destroy(),
>> if PTHREAD_MUTEX_INIT exists.
>> 
>> However, this is wrong for Cygwin.  It defines PTHREAD_MUTEX_INIT, but
>> it still needs a pthread_mutex_destroy() call, because the pthread_mutex_t
>> type is not a trivial one.
>> 
>> Thus, we need a destructor even if __GTHREAD_MUTEX_INIT is defined.
>> 
>> A potential fix would be 
>> 
>> diff --git a/libstdc++-v3/include/bits/std_mutex.h b/libstdc++-v3/include/bits/std_mutex.h
>> index 7ef33fe5d0d7..f060c75abf21 100644
>> --- a/libstdc++-v3/include/bits/std_mutex.h
>> +++ b/libstdc++-v3/include/bits/std_mutex.h
>> @@ -68,6 +68,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>>      __native_type  _M_mutex = __GTHREAD_MUTEX_INIT;
>>  
>>      constexpr __mutex_base() noexcept = default;
>> +#ifdef __CYGWIN__
>> +    ~__mutex_base() noexcept { __gthread_mutex_destroy(&_M_mutex); }
>> +#endif
>>  #else
>>      __native_type  _M_mutex;
>> 

We're going to need a bit more context to evaluate this.  There is no 
file named std_mutex.h in the newlib or Cygwin source trees.  Is this 
perhaps a file in the gcc-g++ source tree?  Or somewhere else?

Can you point us to the original email that started the chain that 
Corinna replied to?

..mark

-- 
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2026   by DJ Delorie     Updated Sep 20 2026