Repository navigation
Conversation
When tables.list names a table that no longer exists, initializing the reftable stack fails. However, reftable_be_init() only records the error and returns a partially initialized ref store with a NULL stack. Read operations then return the saved error, which some callers ignore. For example, for-each-ref silently succeeds without listing any refs. Other paths dereference the missing stack or an uninitialized iterator, so refs verify and for-each-ref --start-after can segfault. The ref-store initializer cannot return an error to its callers. Die with the underlying reftable error instead of returning an unusable store. This also makes individual ref lookups and reflog reads report the storage failure rather than treating refs as missing. Add regression coverage for missing tables and adjust the worktree verification test to expect the earlier initialization failure. Signed-off-by: Harold Hunt <harold@pwrdrvr.com>
Welcome to GitGitGadgetHi @huntharo, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests. Please make sure that either:
You can CC potential reviewers by adding a footer to the PR description with the following syntax: NOTE: DO NOT copy/paste your CC list from a previous GGG PR's description, Also, it is a good idea to review the commit messages one last time, as the Git project expects them in a quite specific form:
It is in general a good idea to await the automated test ("Checks") in this Pull Request before contributing the patches, e.g. to avoid trivial issues such as unportable code. Contributing the patchesBefore you can contribute the patches, your GitHub username needs to be added to the list of permitted users. Any already-permitted user can do that, by adding a comment to your PR of the form Both the person who commented An alternative is the channel Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment If you want to see what email(s) would be sent for a After you submit, GitGitGadget will respond with another comment that contains the link to the cover letter mail in the Git mailing list archive. Please make sure to monitor the discussion in that thread and to address comments and suggestions (while the comments and suggestions will be mirrored into the PR by GitGitGadget, you will still want to reply via mail). If you do not want to subscribe to the Git mailing list just to be able to respond to a mail, you can download the mbox from the Git mailing list archive (click the curl -g --user "<EMailAddress>:<Password>" \
--url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txtTo iterate on your change, i.e. send a revised patch or patch series, you will first want to (force-)push to the same branch. You probably also want to modify your Pull Request description (or title). It is a good idea to summarize the revision by adding something like this to the cover letter (read: by editing the first comment on the PR, i.e. the PR description): To send a new iteration, just add another PR comment with the contents: Need help?New contributors who want advice are encouraged to join git-mentoring@googlegroups.com, where volunteers who regularly contribute to Git are willing to answer newbie questions, give advice, or otherwise provide mentoring to interested contributors. You must join in order to post or view messages, but anyone can join. You may also be able to find help in real time in the developer IRC channel, |
|
/allow |
|
User huntharo is now allowed to use GitGitGadget. |
|
@huntharo please note that the cover letter screams "I was written by AI", and note also that there is at least one highly vocal opponent of AI-generated work on the Git mailing list. You might want to edit or even rewrite this to be more similar to other contributions (have a look at https://lore.kernel.org/git/ to see how cover letters usually look, e.g. lacking headers like "Background" and completely lacking the "Validation" part because that is assumed for high-quality contributions). |
Thanks. The headers and reproduction steps are mine as is the verbose explanation. That's just who I am... the detailed links were collected by my agent. But the biggest problem is my writing style 😂. My biggest fear is that there is not enough info in the write up to trust the patch, but it seems the preference is for less. I'm looking through some examples and will update. |
Background
For the not-yet-default
reftablemode: whentables.listnames a missing table,reftable_be_init()saves the error but returns an unusable ref store with a NULL stack.for-each-refsilently succeeds because callers discard the iterator error;refs verifydereferences the NULL stack, andfor-each-ref --start-aftercan also segfault.Fix Summary
Stop with the underlying reftable diagnostic when initialization fails. The three-line backend change makes ref listing, individual lookups, reflog reads, verification, and fsck fail visibly. Add seven missing-table regression cases and update the existing worktree verification diagnostic for the earlier failure.
Note: I chose to leave the
assertthat checks library misuse above thedieon any other error, to preserve behavior for that case. I chose to make this adiebecause callers are expecting a usable store and there does not appear to be a good way to propagate errors to callers with the existing pattern, and some callers were reporting false success while others were dereferencing NULL and crashing.Reproduction
Reproduction using Git built from the base commit (these commands deliberately remove one table from a freshly created temporary repository):
Before this fix,
for-each-refproduces no output and exits 0;rev-parsereportsNeeded a single revision;refs verifycrashes with SIGSEGV; andfsckreportsrefs died of signal 11. With this fix, all four commands fail withfatal: could not initialize reftable backend: file does not existand no signal crash.This demonstrates handling of an already-corrupted stack; it does not establish that normal operations on current Git create this corruption.
Fix Validation
for-each-refexits 0 with empty output,refs verifyandfor-each-ref --start-afterdie with SIGSEGV, andfsckreportsrefs died of signal 11.could not initialize reftable backend: file does not existwithout a signal crash.make -j8succeeds.t0610-reftable-basics.sh(97 tests),t0611-reftable-httpd.sh(1 test),t0613-reftable-write-options.sh(12 tests), andt0614-reftable-fsck.sh(9 tests): 119 tests total. The HTTP script was rerun outside the sandbox so Apache could bind to localhost.t0612-reftable-jgit-compatibility.shwas invoked and skipped because JGit is not installed.git diff --checkpass.Commit includes
Signed-off-by: Harold Hunt <harold@pwrdrvr.com>.