Re: [PATCH v4] Cygwin: pthread: Fix a race issue introduced by the commit 2c5433e5da82

2024-06-01 Thread Takashi Yano
On Sat, 1 Jun 2024 12:48:07 -0700 (PDT) Jeremy Drake On Sat, 1 Jun 2024, Takashi Yano wrote: > > > + const int destroyed = INT_MIN >> 1; /* 0b1100 */ > > I thought whether or not right shifting a negative number sign-extends was > undefined in the C/C++ standards? It seems tha

Re: [PATCH v4] Cygwin: pthread: Fix a race issue introduced by the commit 2c5433e5da82

2024-06-01 Thread Jeremy Drake via Cygwin-patches
On Sat, 1 Jun 2024, Takashi Yano wrote: > + const int destroyed = INT_MIN >> 1;/* 0b1100 */ I thought whether or not right shifting a negative number sign-extends was undefined in the C/C++ standards?

[PATCH v4] Cygwin: pthread: Fix a race issue introduced by the commit 2c5433e5da82

2024-06-01 Thread Takashi Yano
To avoid race issues, pthread::once() uses pthread_mutex. This caused the handle leak which was fixed by the commit 2c5433e5da82. However, this fix introduced another race issue, i.e., the mutex may be used after it is destroyed. This patch fixes the issue. Special thanks to Bruno Haible for discus