Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent potential segfault in scalar reconfigure --all #647

Merged

Conversation

derrickstolee
Copy link
Collaborator

@derrickstolee derrickstolee commented May 1, 2024

See gitgitgadget#1724 for the upstream fix. This includes an extra detail around the context of that change that will require some reaction in microsoft/git. Please see the fixup! and merge commit messages for details.

This merges in the upstream commit that is going into master soon.

This microsoft/git-specific change went through a few refactors to get
into this state, but now it's sub-optimal: it "succeeds" if setting the
config -or- toggling maintenance succeeds. The logic used to be that it
set a failure in either of these modes, but the variable was changed to
be a success.

Merge these if statements together. This should simplify the logic for
now. The resulting squashed commit could also be upstreamed.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
@derrickstolee derrickstolee self-assigned this May 1, 2024
derrickstolee and others added 2 commits May 7, 2024 17:51
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
…-vfs-2.45.0

TODO: Replace the right-hand side of this merge with the upstream
version of this change. Note that this was an easy merge with the
left-hand side's fixup! commit squashing two if blocks together.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
@dscho dscho force-pushed the scalar-reconfigure-vfs-2.45.0 branch from 68b0d4c to 633892e Compare May 10, 2024 07:59
@derrickstolee derrickstolee marked this pull request as ready for review May 10, 2024 13:25
@dscho dscho merged commit a7790b9 into microsoft:vfs-2.45.0 May 14, 2024
47 of 48 checks passed
dscho added a commit that referenced this pull request May 14, 2024
I noticed the `osx-gcc` job failing in #647 so I found this upstream fix
from @peff. Merging now to unblock PR builds in `microsoft/git`.
dscho added a commit that referenced this pull request May 14, 2024
I noticed the `osx-gcc` job failing in #647 so I found this upstream fix
from @peff. Merging now to unblock PR builds in `microsoft/git`.
dscho added a commit that referenced this pull request May 14, 2024
I noticed the `osx-gcc` job failing in #647 so I found this upstream fix
from @peff. Merging now to unblock PR builds in `microsoft/git`.
dscho added a commit that referenced this pull request May 14, 2024
I noticed the `osx-gcc` job failing in #647 so I found this upstream fix
from @peff. Merging now to unblock PR builds in `microsoft/git`.
dscho added a commit that referenced this pull request Jun 3, 2024
I noticed the `osx-gcc` job failing in #647 so I found this upstream fix
from @peff. Merging now to unblock PR builds in `microsoft/git`.
dscho added a commit that referenced this pull request Jun 3, 2024
I noticed the `osx-gcc` job failing in #647 so I found this upstream fix
from @peff. Merging now to unblock PR builds in `microsoft/git`.
dscho added a commit that referenced this pull request Jun 3, 2024
I noticed the `osx-gcc` job failing in #647 so I found this upstream fix
from @peff. Merging now to unblock PR builds in `microsoft/git`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants