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

Re: [RFC/PATCH 0/6] build argv_array into run-command

From
Junio C Hamano <gitster@pobox.com>
Date
May 15, 2014, 16:48 UTC
Message-ID
<xmqqiop7gf85.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20140515082943.GA26473@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 22 quoted lines
> The memory ownership of the "argv" array of a "struct child_process" can
> be tricky. The child_process does not own the memory, but it must remain
> valid until finish_command runs. That's easy for cases where we call
> start_command and finish_command in the same function: you can use a
> local array variable, or use an argv_array and cleanup afterwards.
>
> But it's easy to screw up in cases where you want to start a command in
> one function and finish it in another, either by pointing to invalid
> storage during finish_command, or by leaking dynamically allocated
> memory.
>
> This series sticks an argv_array inside the "struct child_process",
> which we clean up automatically.  Because some callers might not want to
> use it, it's optional. If you provide "argv", we use that, and
> otherwise fall back to the internal array.
>
> The first commit below does that. The second fixes an uninitialized
> memory access. 3, 4, and 5 plug memory leaks. 6 is just a cleanup for
> consistency with the changes in 4 and 5.
>
> And in 2, 3, and 5 we are introducing argv_array into new spots, which
> simplifies the code and gets rid of magic numbers.
Nicely done.
Previous: Jeff King
Message 9 of 9 in “build argv_array into run-command”
  1. 0/6 build argv_array into run-commandJeff King, May 15, 2014
  2. 1/6 run-command: store an optional argv_arrayJeff King, May 15, 2014
  3. 2/6 run_column_filter: use argv_arrayJeff King, May 15, 2014
  4. 3/6 git_connect: use argv_arrayJeff King, May 15, 2014
  5. 4/6 get_helper: use run-command's internal argv_arrayJeff King, May 15, 2014
  6. 5/6 get_exporter: use argv_arrayJeff King, May 15, 2014
  7. 6/6 get_importer: use run-command's internal argv_arrayJeff King, May 15, 2014
  8. 7/6 argv-array: drop "detach" codeJeff King, May 15, 2014
  9. Junio C HamanoMay 15, 2014

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.