git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH] vreportf: ensure sensible ordering of normal and error output

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Nov 30, 2021, 14:15 UTC
Message-ID
<CAPig+cT4+i-R74Lnt9RgkXkDVqx5nThqEMvKG05SP6iRSSsm2w@mail.gmail.com>
In-Reply-To
<YaXPUe9Sz3JBlzYL@coredump.intra.peff.net>
On Tue, Nov 30, 2021 at 2:14 AM Jeff King <peff@peff.net> wrote:
Show 15 quoted lines
>   - flushing causes us to block. This implies our stdout is connected to
>     a pipe or socket, and the other side is not expecting to read. A
>     plausible case here is a client sending us a big input which we find
>     to be bogus (maybe index-pack checking an incoming pack). We call
>     die() to complain about the input, but the client is still writing.
>     In the current code, we'd write out our error and then exit; the
>     client would get SIGPIPE or a write() error and abort. But with a
>     flush here, we could block writing back to the client, and now we're
>     in a deadlock; they are trying to write to us but we are no longer
>     reading, and we are blocked trying to get out a little bit of
>     irrelevant stdout data.
>
> Of the two, the deadlock case worries me more, just because it would be
> quiet subtle and racy. As I said, I think we may be OK, but my reasoning
> there is pretty hand-wavy.
Flushing stdout only if it is attached to a terminal:
    if (isatty(1))
        fflush(stdout);

should address this potential-deadlock concern, I think(?). It's rather ugly, though, and entering the realm of too-much-special-casing; it feels like it has the potential of heading down a rabbit hole where we find more cases which need to be handled specially.

Previous: Jeff KingNext: Jeff King
Message 7 of 17 in “vreportf: ensure sensible ordering of normal and error output”
  1. vreportf: ensure sensible ordering of normal and error outputEric Sunshine, Nov 30, 2021
  2. Junio C HamanoNov 30, 2021
  3. Jeff KingNov 30, 2021
  4. Jeff KingNov 30, 2021
  5. Ævar Arnfjörð BjarmasonNov 30, 2021
  6. Jeff KingNov 30, 2021
  7. Eric SunshineNov 30, 2021
  8. Jeff KingNov 30, 2021
  9. Eric SunshineNov 30, 2021
  10. Eric SunshineNov 30, 2021
  11. "breaking" command output message parsing (was: [RFC PATCH] vreportf: ensure sensible ordering of normal and error output)Ævar Arnfjörð Bjarmason, Dec 1, 2021
  12. Eric SunshineDec 1, 2021
  13. Jeff KingNov 30, 2021
  14. Eric SunshineDec 1, 2021
  15. Eric SunshineDec 1, 2021
  16. Ævar Arnfjörð BjarmasonDec 1, 2021
  17. Junio C HamanoDec 2, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.