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

Re: [PATCH v3] scalar: avoid segfault in reconfigure --all

From
Patrick Steinhardt <ps@pks.im>
Date
May 8, 2024, 03:42 UTC
Message-ID
<Zjr0nmJib_1EtdJU@tanuki>
In-Reply-To
<pull.1724.v3.git.1715126749391.gitgitgadget@gmail.com>
On Wed, May 08, 2024 at 12:05:49AM +0000, Derrick Stolee via GitGitGadget wrote:
Show 32 quoted lines
> From: Derrick Stolee <stolee@gmail.com>
> 
> During the latest v2.45.0 update, 'scalar reconfigure --all' started to
> segfault on my machine. Breaking it down via the debugger, it was
> faulting on a NULL reference to the_hash_algo, which is a macro pointing
> to the_repository->hash_algo.
> 
> In my case, this is due to one of my repositories having a detached HEAD,
> which requires get_oid_hex() to parse that the HEAD reference is valid.
> Another way to cause a failure is to use the "includeIf.onbranch" config
> key, which will lead to a BUG() statement.
> 
> My first inclination was to try to refactor cmd_reconfigure() to execute
> 'git for-each-repo' instead of this loop. In addition to the difficulty
> of executing 'scalar reconfigure' within 'git for-each-repo', it would
> be difficult to perform the clean-up logic for non-existent repos if we
> relied on that child process.
> 
> Instead, I chose to move the temporary repo to be within the loop and
> reinstate the_repository to its old value after we are done performing
> logic on the current array item.
> 
> Add tests to t9210-scalar.sh to test 'scalar reconfigure --all' with
> multiple registered repos. There are two different ways that the old
> use of the_repository could trigger bugs. These issues are being solved
> independently to be more careful about the_repository being
> uninitialized, but the change in this patch around the use of
> the_repository is still a good safety precaution.
> 
> Co-authored-by: Patrick Steinhardt <ps@pks.im>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> Signed-off-by: Derrick Stolee <stolee@gmail.com>
Thanks, this version looks good to me!
Patrick
Previous: Derrick Stolee via GitGitGadget
Message 7 of 7 in “scalar: avoid segfault in reconfigure --all”
  1. scalar: avoid segfault in reconfigure --allDerrick Stolee via GitGitGadget, Apr 30, 2024
  2. Patrick SteinhardtMay 2, 2024
  3. Derrick StoleeMay 4, 2024
  4. scalar: avoid segfault in reconfigure --allDerrick Stolee via GitGitGadget, May 5, 2024
  5. Patrick SteinhardtMay 6, 2024
  6. scalar: avoid segfault in reconfigure --allDerrick Stolee via GitGitGadget, May 8, 2024
  7. Patrick SteinhardtMay 8, 2024

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.