mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Alexey Izbyshev <izbyshev@ispras.ru>
To: musl@lists.openwall.com
Subject: Re: [musl] synccall patches
Date: Thu, 02 Nov 2023 00:28:59 +0700	[thread overview]
Message-ID: <2193f3bd74f006d5bd44ecf5af6187fa@ispras.ru> (raw)
In-Reply-To: <20231101130033.GR4163@brightrain.aerifal.cx>

On 2023-11-01 20:00, Rich Felker wrote:
> On Tue, Oct 31, 2023 at 05:21:01PM +0100, Markus Wichmann wrote:
>> Then I noticed that __synccall() has a logic bug explained in the 
>> commit
>> message. It wouldn't be a bug if semaphores had any kind of preference
>> for the thread that has waited longest or something, but musl does not
>> implement something like this. And the kernel explicitly documents 
>> that
>> FUTEX_WAKE will wake a random thread.
>> 
>> At first I thought the best solution would be to forego the serialized
>> execution of the callback; just release all threads in line 97 (and 
>> then
>> fix the callbacks to cope with parallel execution). But BSD semaphores
>> have no way to do that, and a mass-release loop like the one on line 
>> 110
>> would have the same issue as given here. It would only be less likely 
>> to
>> happen, with the likelihood rising with the number of threads. So a 
>> new
>> semaphore it is.
> 
> I think your assessment of the problem is correct and I think your fix
> works but I need to look at it in a little more detail. Review from
> others familiar with this stuff would be very welcome too.
> 
I looked at synccall code back when it was rewritten in commit 
e4235d70672d9751d7718ddc2b52d0b426430768, but I missed this bug. Markus' 
patch looks good to me.

Alexey

      parent reply	other threads:[~2023-11-01 17:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31 16:21 Markus Wichmann
2023-11-01 13:00 ` Rich Felker
2023-11-01 13:53   ` Markus Wichmann
2023-11-01 17:05     ` Rich Felker
2023-11-02 16:42       ` Markus Wichmann
2023-11-01 17:28   ` Alexey Izbyshev [this message]

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=2193f3bd74f006d5bd44ecf5af6187fa@ispras.ru \
    --to=izbyshev@ispras.ru \
    --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).