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

ERANGE strikes again: RFH #498

Closed
wants to merge 1 commit into from

Conversation

j6t
Copy link

@j6t j6t commented Dec 22, 2019

I have to build with SNPRINTF_RETURNS_BOGUS. We know already that compat/snprintf overwrites errno with ERANGE in the case where a too small buffer is passed to the function.

I observe failures such as this one in t0410-partial-clone.sh:

++ git -C repo fsck
Checking object directories: 100% (256/256), done.
Checking objects: 100% (1/1), done.
fatal: failed to read object 3836707...snip...6591523: Result too large

The messages is from read_object_file_extended() in sha1-file.c.
It looks like we call into strbuf after a lower-level error return,
but before the error is checked. Does someone know where this
could happen?

The reason I'm asking is that today's tool chain is sufficiently broken for me
on Windows that I can't use the debugger. A hint where to start debugging
with fprintf would be helpful.

The incarnation of vsnprintf that I have to use requires our replacement
from vsnprintf, because it returns -1 when the resulting string does not
fit into the supplied buffer. An additional behavior is that it returns
ERANGE when this overflow happens.

There seem to be code paths in the Windows compatibility layer where
a usable errno value is turned into ERANGE. A symptom is that in
t0410-partial-clone.sh I observe

++ git -C repo fsck
Checking object directories: 100% (256/256), done.
Checking objects: 100% (1/1), done.
fatal: failed to read object 3836707...snip...6591523: Result too large

where the expected result is

Checking object directories: 100% (256/256), done.
Checking objects: 100% (1/1), done.
dangling tag e5f4cb9fd329c512b08fb81a8e6b1f5e27658263

There are other cases where the wrong error happens as well:

 t0000-basic.sh
 t5310-pack-bitmaps.sh
 t5318-commit-graph.sh
 t5500-fetch-pack.sh
 t5616-partial-clone.sh
 t6050-replace.sh
 t6501-freshen-objects.sh

Unfortunately, due to a lacking tool chain, I am unable to dig into the
root cause of the problem. So, let's do the second best thing: ensure
that errno is preserved across the compatibility vsnprintf.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
@gitgitgadget
Copy link

gitgitgadget bot commented Dec 22, 2019

Welcome to GitGitGadget

Hi @j6t, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests.

Please make sure that this Pull Request has a good description, as it will be used as cover letter.

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:

  • the lines should not exceed 76 columns,
  • the first line should be like a header and typically start with a prefix like "tests:" or "commit:", and
  • the commit messages' body should be describing the "why?" of the change.
  • Finally, the commit messages should end in a Signed-off-by: line matching the commits' author.

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 patches

Before 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 /allow. A good way to find other contributors is to locate recent pull requests where someone has been /allowed:

Both the person who commented /allow and the PR author are able to /allow you.

An alternative is the channel #git-devel on the FreeNode IRC network:

<newcontributor> I've just created my first PR, could someone please /allow me? https://github.com/gitgitgadget/git/pull/12345
<veteran> newcontributor: it is done
<newcontributor> thanks!

Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment /submit.

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.

If you want to see what email(s) would be sent for a submit request, add a PR comment /preview to have the email(s) sent to you. You must have a public GitHub email address for this.

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 ("raw") file corresponding to the mail you want to reply to from the Git mailing list. If you use GMail, you can upload that raw mbox file via:

curl -g --user "<EMailAddress>:<Password>" --url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txt

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, #git-devel on Freenode. Remember that IRC does not support offline messaging, so if you send someone a private message and log out, they cannot respond to you. The scrollback of #git-devel is archived, though.

@dscho
Copy link
Member

dscho commented Dec 25, 2019

/allow

@gitgitgadget
Copy link

gitgitgadget bot commented Dec 25, 2019

User j6t is now allowed to use GitGitGadget.

WARNING: j6t has no public email address set on GitHub

@j6t
Copy link
Author

j6t commented Dec 29, 2019

I retract this patch for now. I have asked the mailing list to clarify whether restoration of errno like I do in this patch is actually necessary, or whether the caller that depends on that errno remains unmodified is bogus.

@j6t j6t closed this Dec 29, 2019
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.

2 participants