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

Fix "BUG: refs/files-backend.c:465: returning non-zero -1, should have set myerr!" #3678

Merged
merged 1 commit into from
Feb 1, 2022

Conversation

dscho
Copy link
Member

@dscho dscho commented Feb 1, 2022

This fixes #3674.

Since df3458e (refs API: make parse_loose_ref_contents() not set
errno, 2021-10-16), `files_read_raw_ref()` assumes that `errno` is
always set to a non-zero value upon failure. It even goes so far as to
hard-code that assumption in a `BUG()` when that assumption is not met,
rather than fail gracefully.

According to
https://pubs.opengroup.org/onlinepubs/9699919799/functions/lstat.html,
`lstat()` shall indeed set `errno` upon failure, and
https://pubs.opengroup.org/onlinepubs/9699919799/functions/errno.html
indicates that indeed, the code may rely on `errno` being set to a
non-zero value upon failure.

In `fscache_lstat()`, we did not set `errno` upon a cache miss (which
indicates that the item did not exist at the time the `lstat()` values
were cached), and therefore we now trigger this problem all the time.

Let's set `errno=ENOENT` when no entry was found.

This fixes git-for-windows#3674

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to git-for-windows/build-extra that referenced this pull request Feb 1, 2022
A [bug](git-for-windows/git#3674) in FSCache
that triggered by a patch that made it into Git for Windows v2.35.0
[was fixed](git-for-windows/git#3678).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho merged commit 5437f0f into git-for-windows:main Feb 1, 2022
@dscho dscho deleted the fix-fscache_lstat-bug branch February 1, 2022 17:06
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 1, 2022 17:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 2, 2022 08:35 Inactive
@dscho dscho temporarily deployed to monitor-components February 2, 2022 08:35 Inactive
@dscho dscho temporarily deployed to monitor-components February 2, 2022 08:35 Inactive
@dscho dscho temporarily deployed to monitor-components February 2, 2022 08:35 Inactive
@dscho dscho temporarily deployed to monitor-components February 7, 2022 17:31 Inactive
@dscho dscho temporarily deployed to monitor-components February 7, 2022 17:31 Inactive
@dscho dscho temporarily deployed to monitor-components February 7, 2022 17:31 Inactive
@dscho dscho temporarily deployed to monitor-components February 7, 2022 17:31 Inactive
@dscho dscho temporarily deployed to monitor-components February 7, 2022 17:31 Inactive
@dscho dscho temporarily deployed to monitor-components February 7, 2022 17:31 Inactive
@dscho dscho temporarily deployed to monitor-components February 7, 2022 17:31 Inactive
@dscho dscho temporarily deployed to monitor-components February 7, 2022 17:31 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
@dscho dscho temporarily deployed to monitor-components February 8, 2022 08:34 Inactive
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.

BUG: refs/files-backend.c:465: returning non-zero -1, should have set myerr!
1 participant