Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220315195056.GA8457@voyager>
Date: Tue, 15 Mar 2022 20:50:56 +0100
From: Markus Wichmann <nullplan@....net>
To: musl@...ts.openwall.com
Subject: Re: Possible PEBKAC or Bug in musl Semaphores and/or Mutexes

On Tue, Mar 15, 2022 at 12:55:38PM -0600, Gavin Howard wrote:
> I am pretty sure that this is the right place and that it is a bug in
> musl.

Once more we find someone blaming the implementation for their own
mistake. From your repository:

| y_Status
| y_strucon_rwlock_wrlock(y_strucon_rwlock* l)
| {
| 	y_ThreadData d = y_strucon_thread_os_get();
|
| 	yc_assert(l != NULL, YC_ASSERT_NULL);
| 	yc_assert(d != NULL, YC_ASSERT_NULL);
|
| 	y_THREAD_TRYLOCK1(d);
|
| 	y_Status s = y_strucon_rwlock_os_rdlock(l);
|
| 	return s;
| }

The mistake is in this function. See what the function is called and
what subfunction it calls? No wonder multiple threads can take the lock
simultaneously.

Also, while reading I found a glaring mistake in y_THREAD_TRYUNLOCK1(),
which I shall leave as homework to the reader.

Ciao,
Markus

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.