<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/run-command.c, branch gitk-resize-error</title>
<subtitle>Fork of git SCM with my patches.</subtitle>
<id>http://git.kilabit.info/git/atom?h=gitk-resize-error</id>
<link rel='self' href='http://git.kilabit.info/git/atom?h=gitk-resize-error'/>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/'/>
<updated>2022-01-10T19:52:53Z</updated>
<entry>
<title>Merge branch 'ab/usage-die-message'</title>
<updated>2022-01-10T19:52:53Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-01-10T19:52:53Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=4b51386bbfc5d26e552c3c4be135e31cd2f64b44'/>
<id>urn:sha1:4b51386bbfc5d26e552c3c4be135e31cd2f64b44</id>
<content type='text'>
Code clean-up to hide vreportf() from public API.

* ab/usage-die-message:
  config API: use get_error_routine(), not vreportf()
  usage.c + gc: add and use a die_message_errno()
  gc: return from cmd_gc(), don't call exit()
  usage.c API users: use die_message() for error() + exit 128
  usage.c API users: use die_message() for "fatal :" + exit 128
  usage.c: add a die_message() routine
</content>
</entry>
<entry>
<title>Merge branch 'ab/run-command'</title>
<updated>2021-12-15T17:39:47Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-12-15T17:39:47Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=832ec72c3e15820c3b728b3a56398655d7bb7cb3'/>
<id>urn:sha1:832ec72c3e15820c3b728b3a56398655d7bb7cb3</id>
<content type='text'>
API clean-up.

* ab/run-command:
  run-command API: remove "env" member, always use "env_array"
  difftool: use "env_array" to simplify memory management
  run-command API: remove "argv" member, always use "args"
  run-command API users: use strvec_push(), not argv construction
  run-command API users: use strvec_pushl(), not argv construction
  run-command tests: use strvec_pushv(), not argv assignment
  run-command API users: use strvec_pushv(), not argv assignment
  upload-archive: use regular "struct child_process" pattern
  worktree: stop being overly intimate with run_command() internals
</content>
</entry>
<entry>
<title>Merge branch 'jk/t7006-sigpipe-tests-fix'</title>
<updated>2021-12-10T22:35:13Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-12-10T22:35:13Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=97991dfab7bea2f347bbea1ae7494afa72a50931'/>
<id>urn:sha1:97991dfab7bea2f347bbea1ae7494afa72a50931</id>
<content type='text'>
The function to cull a child process and determine the exit status
had two separate code paths for normal callers and callers in a
signal handler, and the latter did not yield correct value when the
child has caught a signal.  The handling of the exit status has
been unified for these two code paths.  An existing test with
flakiness has also been corrected.

* jk/t7006-sigpipe-tests-fix:
  t7006: simplify exit-code checks for sigpipe tests
  t7006: clean up SIGPIPE handling in trace2 tests
  run-command: unify signal and regular logic for wait_or_whine()
</content>
</entry>
<entry>
<title>usage.c API users: use die_message() for "fatal :" + exit 128</title>
<updated>2021-12-07T21:25:15Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-12-07T18:26:30Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=e081a7c3b7290c50c817598e5f2686d068540762'/>
<id>urn:sha1:e081a7c3b7290c50c817598e5f2686d068540762</id>
<content type='text'>
Change code that printed its own "fatal: " message and exited with a
status code of 128 to use the die_message() function added in a
preceding commit.

This change also demonstrates why the return value of
die_message_routine() needed to be that of "report_fn". We have
callers such as the run-command.c::child_err_spew() which would like
to replace its error routine with the return value of
"get_die_message_routine()".

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>run-command API: remove "env" member, always use "env_array"</title>
<updated>2021-11-26T06:15:08Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-11-25T22:52:24Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=c7c4bdeccf3e737e6e674cd9f0828922e629ab06'/>
<id>urn:sha1:c7c4bdeccf3e737e6e674cd9f0828922e629ab06</id>
<content type='text'>
Remove the "env" member from "struct child_process" in favor of always
using the "env_array". As with the preceding removal of "argv" in
favor of "args" this gets rid of current and future oddities around
memory management at the API boundary (see the amended API docs).

For some of the conversions we can replace patterns like:

    child.env = env-&gt;v;

With:

    strvec_pushv(&amp;child.env_array, env-&gt;v);

But for others we need to guard the strvec_pushv() with a NULL check,
since we're not passing in the "v" member of a "struct strvec",
e.g. in the case of tmp_objdir_env()'s return value.

Ideally we'd rename the "env_array" member to simply "env" as a
follow-up, since it and "args" are now inconsistent in not having an
"_array" suffix, and seemingly without any good reason, unless we look
at the history of how they came to be.

But as we've currently got 122 in-tree hits for a "git grep env_array"
let's leave that for now (and possibly forever). Doing that rename
would be too disruptive.

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>run-command API: remove "argv" member, always use "args"</title>
<updated>2021-11-26T06:15:07Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-11-25T22:52:22Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=d3b2159712019a06f1f495d3e42bd6aa6e76e848'/>
<id>urn:sha1:d3b2159712019a06f1f495d3e42bd6aa6e76e848</id>
<content type='text'>
Remove the "argv" member from the run-command API, ever since "args"
was added in c460c0ecdca (run-command: store an optional argv_array,
2014-05-15) being able to provide either "argv" or "args" has led to
some confusion and bugs.

If we hadn't gone in that direction and only had an "argv" our
problems wouldn't have been solved either, as noted in [1] (and in the
documentation amended here) it comes with inherent memory management
issues: The caller would have to hang on to the "argv" until the
run-command API was finished. If the "argv" was an argument to main()
this wasn't an issue, but if it it was manually constructed using the
API might be painful.

We also have a recent report[2] of a user of the API segfaulting,
which is a direct result of it being complex to use. This commit
addresses the root cause of that bug.

This change is larger than I'd like, but there's no easy way to avoid
it that wouldn't involve even more verbose intermediate steps. We use
the "argv" as the source of truth over the "args", so we need to
change all parts of run-command.[ch] itself, as well as the trace2
logging at the same time.

The resulting Windows-specific code in start_command() is a bit nasty,
as we're now assigning to a strvec's "v" member, instead of to our own
"argv". There was a suggestion of some alternate approaches in reply
to an earlier version of this commit[3], but let's leave larger a
larger and needless refactoring of this code for now.

1. http://lore.kernel.org/git/YT6BnnXeAWn8BycF@coredump.intra.peff.net
2. https://lore.kernel.org/git/20211120194048.12125-1-ematsumiya@suse.de/
3. https://lore.kernel.org/git/patch-5.5-ea1011f7473-20211122T153605Z-avarab@gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>run-command API users: use strvec_pushv(), not argv assignment</title>
<updated>2021-11-26T06:15:07Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-11-25T22:52:18Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=6def0ff8785eb12ccc24ceebea04355e13ae24b6'/>
<id>urn:sha1:6def0ff8785eb12ccc24ceebea04355e13ae24b6</id>
<content type='text'>
Migrate those run-command API users that assign directly to the "argv"
member to use a strvec_pushv() of "args" instead.

In these cases it did not make sense to further refactor these
callers, e.g. daemon.c could be made to construct the arguments closer
to handle(), but that would require moving the construction from its
cmd_main() and pass "argv" through two intermediate functions.

It would be possible for a change like this to introduce a regression
if we were doing:

      cp.argv = argv;
      argv[1] = "foo";

And changed the code, as is being done here, to:

      strvec_pushv(&amp;cp.args, argv);
      argv[1] = "foo";

But as viewing this change with the "-W" flag reveals none of these
functions modify variable that's being pushed afterwards in a way that
would introduce such a logic error.

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>run-command: unify signal and regular logic for wait_or_whine()</title>
<updated>2021-11-22T23:43:18Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2021-11-22T21:28:13Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=96bfb2d8ce221d31b3da08a49a455e316dbef7fb'/>
<id>urn:sha1:96bfb2d8ce221d31b3da08a49a455e316dbef7fb</id>
<content type='text'>
Since 507d7804c0 (pager: don't use unsafe functions in signal handlers,
2015-09-04), we have a separate code path in wait_or_whine() for the
case that we're in a signal handler. But that code path misses some of
the cases handled by the main logic.

This was improved in be8fc53e36 (pager: properly log pager exit code
when signalled, 2021-02-02), but that covered only case: actually
returning the correct error code. But there are some other cases:

  - if waitpid() returns failure, we wouldn't notice and would look at
    uninitialized garbage in the status variable; it's not clear if it's
    possible to trigger this or not

  - if the process exited by signal, then we would still report "-1"
    rather than the correct signal code

This latter case even had a test added in be8fc53e36, but it doesn't
work reliably. It sets the pager command to:

  &gt;pager-used; test-tool sigchain

The latter command will die by signal, but because there are multiple
commands, there will be a shell in between. And it's the shell whose
waitpid() call will see the signal death, and it will then exit with
code 143, which is what Git will see.

To make matters even more confusing, some shells (such as bash) will
realize that there's nothing for the shell to do after test-tool
finishes, and will turn it into an exec. So the test was only checking
what it thought when /bin/sh points to a shell like bash (we're relying
on the shell used internally by Git to spawn sub-commands here, so even
running the test under bash would not be enough).

This patch adjusts the tests to explicitly call "exec" in the pager
command, which produces a consistent outcome regardless of shell. Note
that without the code change in this patch it _should_ fail reliably,
but doesn't. That test, like its siblings, tries to trigger SIGPIPE in
the git-log process writing to the pager, but only do so racily. That
will be fixed in a follow-on patch.

For the code change here, we have two options:

  - we can teach the in_signal code to handle WIFSIGNALED()

  - we can stop returning early when in_signal is set, and instead
    annotate individual calls that we need to skip in this case

The former is a simpler patch, but means we're essentially duplicating
all of the logic. So instead I went with the latter. The result is a
bigger patch, and we do run the risk of new code being added but
forgetting to handle in_signal. But in the long run it seems more
maintainable.

I've skipped any non-trivial calls for the in_signal case, like calling
error(). We'll also skip the call to clear_child_for_cleanup(), as we
were before. This is arguably the wrong thing to do, since we wouldn't
want to try to clean it up again. But:

  - we can't call it as-is, because it calls free(), which we must avoid
    in a signal handler (we'd have to pass in_signal so it can skip the
    free() call)

  - we'll only go through the list of children to clean once, since our
    cleanup_children_on_signal() handler pops itself after running (and
    then re-raises, so eventually we'd just exit). So this cleanup only
    matters if a process is on the cleanup list _and_ it has a separate
    handler to clean itself up. Which is questionable in the first place
    (and AFAIK we do not do).

  - double-cleanup isn't actually that bad anyway. waitpid() will just
    return an error, which we won't even report because of in_signal.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'vd/pthread-setspecific-g11-fix'</title>
<updated>2021-11-04T19:07:47Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-11-04T19:07:47Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=a73934c32094339ed41f4134ea8eb4df772f9e69'/>
<id>urn:sha1:a73934c32094339ed41f4134ea8eb4df772f9e69</id>
<content type='text'>
One CI task based on Fedora image noticed a not-quite-kosher
consturct recently, which has been corrected.

* vd/pthread-setspecific-g11-fix:
  async_die_is_recursing: work around GCC v11.x issue on Fedora
</content>
</entry>
<entry>
<title>async_die_is_recursing: work around GCC v11.x issue on Fedora</title>
<updated>2021-11-04T06:12:10Z</updated>
<author>
<name>Victoria Dye</name>
<email>vdye@github.com</email>
</author>
<published>2021-11-04T04:01:03Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=4b540cf913b8f528fadb9357530a34ea0dc09737'/>
<id>urn:sha1:4b540cf913b8f528fadb9357530a34ea0dc09737</id>
<content type='text'>
This fix corrects an issue found in the `dockerized(pedantic, fedora)` CI
build, first appearing after the introduction of a new version of the Fedora
docker image version. This image includes a version of `glibc` with the
attribute `__attr_access_none` added to `pthread_setspecific` [1], the
implementation of which only exists for GCC 11.X - the version included in
the Fedora image. The attribute requires that the pointer provided in the
second argument of `pthread_getspecific` must, if not NULL, be a pointer to
a valid object. In the usage in `async_die_is_recursing`, `(void *)1` is not
valid, causing the error.

This fix imitates a workaround added in SELinux [2] by using the pointer to
the static `async_die_counter` itself as the second argument to
`pthread_setspecific`. This guaranteed non-NULL, valid pointer matches the
intent of the current usage while not triggering the build error.

[1] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=a1561c3bbe8
[2] https://lore.kernel.org/all/20211021140519.6593-1-cgzones@googlemail.com/

Co-authored-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Victoria Dye &lt;vdye@github.com&gt;
Acked-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
