Skip to content

Commit 2644508

Browse files
committed
Cygwin: message queues: avoid deadlocks in multi-threaded processes
Deadlocks have been observed if the message queue functions are called from different threads in the same process. Remove incorrectly locking the descriptor table while accessing the message queue fhandler, potentially calling blocking functions. Fixes: 46f3b0c ("Cygwin: POSIX msg queues: move all mq_* functionality into fhandler_mqueue") Reported-by: Christian Franke <[email protected]> Signed-off-by: Corinna Vinschen <[email protected]> (cherry picked from commit fe6ddc1)
1 parent 5a58110 commit 2644508

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

winsup/cygwin/posix_ipc.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ mq_getattr (mqd_t mqd, struct mq_attr *mqstat)
224224
{
225225
int ret = -1;
226226

227-
cygheap_fdget fd ((int) mqd, true);
227+
cygheap_fdget fd ((int) mqd);
228228
if (fd >= 0)
229229
{
230230
fhandler_mqueue *fh = fd->is_mqueue ();
@@ -241,7 +241,7 @@ mq_setattr (mqd_t mqd, const struct mq_attr *mqstat, struct mq_attr *omqstat)
241241
{
242242
int ret = -1;
243243

244-
cygheap_fdget fd ((int) mqd, true);
244+
cygheap_fdget fd ((int) mqd);
245245
if (fd >= 0)
246246
{
247247
fhandler_mqueue *fh = fd->is_mqueue ();
@@ -258,7 +258,7 @@ mq_notify (mqd_t mqd, const struct sigevent *notification)
258258
{
259259
int ret = -1;
260260

261-
cygheap_fdget fd ((int) mqd, true);
261+
cygheap_fdget fd ((int) mqd);
262262
if (fd >= 0)
263263
{
264264
fhandler_mqueue *fh = fd->is_mqueue ();
@@ -276,7 +276,7 @@ mq_timedsend (mqd_t mqd, const char *ptr, size_t len, unsigned int prio,
276276
{
277277
int ret = -1;
278278

279-
cygheap_fdget fd ((int) mqd, true);
279+
cygheap_fdget fd ((int) mqd);
280280
if (fd >= 0)
281281
{
282282
fhandler_mqueue *fh = fd->is_mqueue ();
@@ -300,7 +300,7 @@ mq_timedreceive (mqd_t mqd, char *ptr, size_t maxlen, unsigned int *priop,
300300
{
301301
int ret = -1;
302302

303-
cygheap_fdget fd ((int) mqd, true);
303+
cygheap_fdget fd ((int) mqd);
304304
if (fd >= 0)
305305
{
306306
fhandler_mqueue *fh = fd->is_mqueue ();

winsup/cygwin/release/3.5.7

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ Fixes:
33

44
- Fix stat() on message queues.
55
Addresses: https://cygwin.com/pipermail/cygwin/2025-January/257186.html
6+
7+
- Avoid deadlocks when calling message queue functions from different threads
8+
in the same process.
9+
Addresses: https://cygwin.com/pipermail/cygwin/2025-January/257120.html

0 commit comments

Comments
 (0)