1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-09 09:06:57 +02:00
git/trace2
Ævar Arnfjörð Bjarmason d3b2159712 run-command API: remove "argv" member, always use "args"
Remove the "argv" member from the run-command API, ever since "args"
was added in c460c0ecdc (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 <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-11-25 22:15:07 -08:00
..
tr2_cfg.c trace2: teach Git to log environment variables 2020-03-23 13:14:53 -07:00
tr2_cfg.h trace2: teach Git to log environment variables 2020-03-23 13:14:53 -07:00
tr2_cmd_name.c
tr2_cmd_name.h
tr2_dst.c Merge branch 'ab/trace2-squelch-gcc-warning' 2021-06-14 13:33:28 +09:00
tr2_dst.h trace2: write discard message to sentinel files 2019-10-05 17:53:51 +09:00
tr2_sid.c Fix spelling errors in code comments 2019-11-10 16:00:54 +09:00
tr2_sid.h
tr2_sysenv.c trace2: teach Git to log environment variables 2020-03-23 13:14:53 -07:00
tr2_sysenv.h trace2: teach Git to log environment variables 2020-03-23 13:14:53 -07:00
tr2_tbuf.c
tr2_tbuf.h
tr2_tgt.h trace2: add trace2_child_ready() to report on background children 2021-09-20 08:57:58 -07:00
tr2_tgt_event.c run-command API: remove "argv" member, always use "args" 2021-11-25 22:15:07 -08:00
tr2_tgt_normal.c run-command API: remove "argv" member, always use "args" 2021-11-25 22:15:07 -08:00
tr2_tgt_perf.c run-command API: remove "argv" member, always use "args" 2021-11-25 22:15:07 -08:00
tr2_tls.c tr2: stop leaking "thread_name" memory 2021-09-07 11:07:59 -07:00
tr2_tls.h