mailing list of musl libc
 help / color / mirror / code / Atom feed
From: a@saur0n.science
To: musl@lists.openwall.com
Subject: [musl] Mutexes are not unlocking
Date: Fri, 20 Nov 2020 08:25:17 +0300	[thread overview]
Message-ID: <1605849917.737458858@f540.i.mail.ru> (raw)

[-- Attachment #1: Type: text/plain, Size: 2005 bytes --]

Hello, all,
I am experiencing a problem with mutexes in musl-libc. The mutex is not unlocked after calling unlock(), this causes getting stuck on attempt to lock it next time. Example code (C++):

void testMutex(std::mutex &mtx, const char * name) {
fprintf(stderr, "-- testing %s --\n", name);
fprintf(stderr, "lock\n");
mtx.lock();
fprintf(stderr, "unlock\n");
mtx.unlock();
fprintf(stderr, "lock2\n");
mtx.lock();
fprintf(stderr, "unlock2\n");
mtx.unlock();
fprintf(stderr, "done\n");
} The problem can be reproduced only on musl-libc, the same binary works well on the system with glibc.
The problem does not reproduce each time, its reproducibility depends on the phase of moon.
The problem can be reproduced more often it the code calling mutex functions is located in the shared library.

Strace (when the problem is reproduced):
[pid   709] writev(2, [{iov_base="-- testing gsMutex --\n", iov_len=22}, {iov_base=NULL, iov_len=0}], 2-- testing gsMutex -- 
) = 22 
[pid   709] writev(2, [{iov_base="", iov_len=0}, {iov_base="lock\n", iov_len=5}], 2lock 
) = 5 
[pid   709] writev(2, [{iov_base="", iov_len=0}, {iov_base="unlock\n", iov_len=7}], 2unlock 
) = 7 
[pid   709] writev(2, [{iov_base="", iov_len=0}, {iov_base="lock2\n", iov_len=6}], 2lock2 
) = 6 
[pid   709] futex(0x7f3a9733e4a4, FUTEX_WAIT_PRIVATE, 2147483664, NULL

Strace (when the problem is not reproduced):
writev(2, [{iov_base="-- testing hhMutex --\n", iov_len=22}, {iov_base=NULL, iov_len=0}], 2-- testing hhMutex -- 
) = 22 
writev(2, [{iov_base="", iov_len=0}, {iov_base="lock\n", iov_len=5}], 2lock 
) = 5 
writev(2, [{iov_base="", iov_len=0}, {iov_base="unlock\n", iov_len=7}], 2unlock 
) = 7 
writev(2, [{iov_base="", iov_len=0}, {iov_base="lock2\n", iov_len=6}], 2lock2 
) = 6 
writev(2, [{iov_base="", iov_len=0}, {iov_base="unlock2\n", iov_len=8}], 2unlock2 
) = 8 
writev(2, [{iov_base="", iov_len=0}, {iov_base="done\n", iov_len=5}], 2done 
) = 5

Thanks in advance for solving the problem.

—— 
Arseniy

[-- Attachment #2: Type: text/html, Size: 3468 bytes --]

             reply	other threads:[~2020-11-20  5:54 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-20  5:25 a [this message]
2020-11-20  5:58 ` Rich Felker
2020-11-21  6:46   ` Re[2]: " a
2020-11-21 15:51     ` Rich Felker
2020-11-22 18:43       ` Re[2]: " Арсений
2020-11-22 19:11         ` Rich Felker
2020-11-22 19:23           ` Florian Weimer
2020-11-22 19:28             ` Rich Felker
2020-11-22 19:45               ` Re[2]: " Арсений
2020-11-22 20:05               ` Арсений
2020-11-23 12:24                 ` Jonathan Wakely
2020-11-23 14:56                   ` Rich Felker
2020-11-23 16:58                     ` Jonathan Wakely
2020-11-23 11:41               ` Jonathan Wakely
2020-11-23 14:53                 ` Rich Felker
2020-11-23 16:19                   ` Jonathan Wakely
2020-11-23 16:51                     ` Rich Felker
2020-11-23 17:10                       ` Jonathan Wakely
2020-11-23 17:18                         ` Florian Weimer
2020-11-23 16:59                     ` Florian Weimer

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=1605849917.737458858@f540.i.mail.ru \
    --to=a@saur0n.science \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).