public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin@cygwin.com
Subject: Re: Possiblly bug of cygwin1.dll
Date: Sun, 21 Jan 2024 20:10:51 +0900	[thread overview]
Message-ID: <20240121201051.795a4405576a97ab8729e273@nifty.ne.jp> (raw)
In-Reply-To: <20240120212427.1e69fd3655ece73ecd508def@nifty.ne.jp>

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 <mutex>
> 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 <future>
> int func() { return 0; }
> int main()
> {
>   for (;;) {
>     std::future<int> 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 <takashi.yano@nifty.ne.jp>

  parent reply	other threads:[~2024-01-21 11:10 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-19 13:44 Takashi Yano
2024-01-19 14:28 ` Corinna Vinschen
2024-01-20  4:18   ` Takashi Yano
2024-01-20  5:13     ` Takashi Yano
2024-01-20  9:13       ` ASSI
2024-01-20 12:24         ` Takashi Yano
2024-01-20 12:46           ` ASSI
2024-01-21 11:10           ` Takashi Yano [this message]
2024-01-21 13:30             ` ASSI
2024-01-22  3:30               ` Takashi Yano
2024-01-22  9:25                 ` Corinna Vinschen
2024-01-22  9:57                   ` Corinna Vinschen
2024-01-22 11:16                     ` Takashi Yano
2024-01-22 11:49                       ` Corinna Vinschen
2024-01-22 12:41                         ` ASSI
2024-01-22 14:54                           ` Corinna Vinschen
2024-01-22 11:06                   ` Takashi Yano
2024-01-22 11:42                     ` Corinna Vinschen
2024-01-23  3:24     ` Kaz Kylheku
2024-01-24 11:55       ` Takashi Yano
2024-01-24 13:05         ` Corinna Vinschen
2024-01-24 13:11           ` Corinna Vinschen
2024-01-24 20:37             ` Kaz Kylheku
2024-01-24 20:08         ` Kaz Kylheku

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240121201051.795a4405576a97ab8729e273@nifty.ne.jp \
    --to=takashi.yano@nifty.ne.jp \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).