git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Johannes Sixt <j6t@kdbg.org>
Cc: git@vger.kernel.org, Aleksey Kliger <alklig@microsoft.com>
Subject: Re: [PATCH] wrapper: add workaround for open() returning EINTR
Date: Fri, 26 Feb 2021 01:17:33 -0500	[thread overview]
Message-ID: <YDiSfXczltBTM+/T@coredump.intra.peff.net> (raw)
In-Reply-To: <YDaZtqRvdZWkyQVp@coredump.intra.peff.net>

On Wed, Feb 24, 2021 at 01:23:51PM -0500, Jeff King wrote:

> > I'm not so much opposed to "enable it all the time" in general, but when
> > we already have an override of open(), like for the Windows case in
> > compat/mingw.h, I find it a bit rough to put another wrapper around it,
> > even more so since we won't have the EINTR problem on Windows due to the
> > absence of signals.
> 
> That's fair. I don't think my new wrapper would interact well with
> mingw_open(). They are both trying to #define open. I think since mine
> comes later in git-compat-util.h, it is probably overriding mingw_open()
> completely on Windows, which is quite bad (we call into my function in
> wrapper.c, but then its "#undef open" means we get the original open(),
> not the previously defined wrapper).

Thanks again for pointing out mingw_open(). The v2 I posted should avoid
any bad interactions there, even if we do end up enabling it all the
time.

By the way, I did notice something funny when looking at mingw_open().
It unconditionally does:

          va_start(args, oflags);
          mode = va_arg(args, int);
          va_end(args);

no matter what we see in oflags. But callers who are not passing O_CREAT
will not provide a third argument at all. So probably it is loading
random trash from the stack and passing it around in the "mode"
variable. This doesn't hurt anything, because ultimately we pass the
trash along to the real open function, which will ignore it without
O_CREAT. But it is definitely undefined behavior to call va_arg() at all
in this instance.

-Peff

      reply	other threads:[~2021-02-26  6:21 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
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 [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

  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=YDiSfXczltBTM+/T@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=alklig@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    /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).