git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Aleksey Kliger <alklig@microsoft.com>
Subject: Re: [PATCH] wrapper: add workaround for open() returning EINTR
Date: Wed, 24 Feb 2021 13:20:44 -0500	[thread overview]
Message-ID: <YDaY/M3Rw+6xwZlf@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqzgzuyqli.fsf@gitster.g>

On Tue, Feb 23, 2021 at 09:36:25PM -0800, Junio C Hamano wrote:

> Jeff King <peff@peff.net> writes:
> 
> > On Tue, Feb 23, 2021 at 11:43:16PM -0500, Jeff King wrote:
> >
> >> The workaround here is enabled all the time, without a Makefile knob,
> >> since it's a complete noop if open() never returns EINTR. I did push it
> >> into its own compat/ source file, though, since it has to #undef our
> >> macro redirection. Putting it in a file with other code risks confusion
> >> if more code is added after that #undef.
> >
> > Whoops, sorry, I had a last-minute change of heart here and just stuck
> > it in wrapper.c with a bit of preprocessor magic to guard it. It felt
> > weird having compat/open.c, when the rest of compat/ is always
> > conditional on Makefile knobs. But I'm happy to go the other way if
> > anybody feels strongly.
> 
> Hmph, just like other workarounds, shouldn't this be "if your
> platform screws this up, define this knob to work it around"?  That
> would make it fit better with the rest of compat/.

I actually started that way, but then I got stuck deciding which
platforms in config.mak.uname to enable it for. We've seen it on Linux
and on macOS. I don't know how prevalent it is on those platforms (or
whether it is indeed a bug that may even get fixed). Since the check is
basically zero-cost at run-time, it seemed like it was worth just being
on guard for it so that nobody ever had to worry about it again.

But I don't feel that strongly. I'd be happy to do it with a Makefile
knob if you prefer.

> I dunno.  A no-op wrapper makes the code less transparent, which I
> am somewhat unhappy.

Yeah. I think the run-time cost is essentially zero, but it does add a
bit of complexity if you are debugging. And handling the magic mode
vararg definitely makes it uglier.

The other thing that gives me pause is that there may be other syscalls
which need the same treatment. Here's a recent discussion that Big Sur
may also return EINTR from the opendir() family:

  https://github.com/dotnet/runtime/issues/47584

Git is presumably susceptible to that, too; it's just that we call
open() a lot more frequently, so that was the obvious one that came up.

I don't think there is a more general way to address this, though. We'd
have to wrap each suspected syscall (but we could presumably at least
tie them all to a single Makefile knob). I'm not excited at the prospect
of preemptively adding such wrappers when we aren't even 100% sure that
there is a problem.

> But a wrapper that is always used even on
> platforms that do not need might give us a better chance of noticing
> a bug in the wrapper itself, making it less likely for us to leave
> only the users of minority broken platforms behind.  So...

That part I'm less worried about. It sounds like we'd want it on for
recent versions of macOS, which would give us pretty wide coverage to
notice a bug.

-Peff

  reply	other threads:[~2021-02-24 18:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-24  4:43 [PATCH] wrapper: add workaround for open() returning EINTR Jeff King
2021-02-24  4:46 ` Jeff King
2021-02-24  5:36   ` Junio C Hamano
2021-02-24 18:20     ` Jeff King [this message]
2021-02-26  6:14       ` [PATCH v2] Makefile: add OPEN_RETURNS_EINTR knob Jeff King
2021-02-26 22:17         ` Junio C Hamano
2021-03-01  9:29           ` [PATCH] config.mak.uname: enable OPEN_RETURNS_EINTR for macOS Big Sur Jeff King
2021-03-01 17:17             ` Junio C Hamano
2021-03-01 23:57             ` Junio C Hamano
2021-03-03 13:41               ` Jeff King
2021-03-04  0:47                 ` Junio C Hamano
2021-02-24  4:50 ` [PATCH] wrapper: add workaround for open() returning EINTR Taylor Blau
2021-02-24  7:20 ` Johannes Sixt
2021-02-24 18:23   ` Jeff King
2021-02-26  6:17     ` Jeff King

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YDaY/M3Rw+6xwZlf@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=alklig@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).