Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Fri, 20 Nov 2020 08:25:17 +0300
From: a@...r0n.science
To: musl@...ts.openwall.com
Subject: Mutexes are not unlocking

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
Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.