git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Denton Liu <liu.denton@gmail.com>
To: "Force.Charlie" <force@forcemz.net>
Cc: git <git@vger.kernel.org>
Subject: Re: Protocol v2: The wrong --shallow-since time format causes git to wait indefinitely
Date: Tue, 19 Nov 2019 15:46:03 -0800	[thread overview]
Message-ID: <20191119234603.GA50851@generichostname> (raw)
In-Reply-To: <tencent_AB1A7466D1F2EF9A84B437705F06A7652709@qq.com>

On Wed, Nov 13, 2019 at 09:00:52AM +0800, Force.Charlie wrote:
> Recently, when I tested my Git Over HTTP server, I found a bug in Git. When we used git -c protocol.version=2 clone --shallow-since , if the time format is wrong, it will cause git to wait indefinitely.
> 
> Github supports Wire Protocol to reproduce, Gitlab does not support it and does not reproduce it.
> 
> The commands that can be retried are as follows:
> 
> ```shell
> # time format wrong
> git -c protocol.version=2 clone https://github.com/git/git.git --shallow-since=20151012
> # trace
> GIT_TRACE=1 GIT_CURL_VERBOSE=1 GIT_TRACE_PACKET=2 git -c protocol.version=2 clone https://github.com/git/git.git --shallow-since=20151012
> ```
> We can see that the server closes the HTTP connection after sending the `shallow-info\n` message, and git-remote-http(s) is still waiting.
> 
> ```
> $ git --version --build-options
> git version 2.24.0
> cpu: x86_64
> no commit associated with this build
> sizeof-long: 8
> sizeof-size_t: 8
> 
> ```
> 
> When the time format is correct, the clone is successful, so this is followed by the shallow-list:
> 
> ```shell
> GIT_TRACE=1 GIT_CURL_VERBOSE=1 GIT_TRACE_PACKET=2 git -c protocol.version=2 clone https://github.com/git/git.git --shallow-since=2015-10-12
> ```
> 
> Github Issues: https://github.com/gitgitgadget/git/issues/457

FWIW, I can reproduce this issue as well. From what I can tell (without
actually looking at any code), it seems like when an invalid
`--shallow-since` is given to the server, it'll hang up on the client.

With protocol v1, the client quits as expected:

	$ git -c protocol.version=1 clone https://github.com/git/git.git --shallow-since=20151012
	Cloning into 'git'...
	fatal: the remote end hung up unexpectedly

However, with v2, I believe that the client doesn't detect the hang up
and just waits forever.

Unfortunately, I don't know the networking code at all and I don't have
time to actually dig into the code. Hopefully this helps a little bit,
though.

Thanks,

Denton

      parent reply	other threads:[~2019-11-19 23:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-13  1:00 Protocol v2: The wrong --shallow-since time format causes git to wait indefinitely =?gb18030?B?Rm9yY2UuQ2hhcmxpZQ==?=
2019-11-13  3:42 ` Junio C Hamano
2019-11-19 23:36   ` Denton Liu
2019-11-19 23:46 ` Denton Liu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191119234603.GA50851@generichostname \
    --to=liu.denton@gmail.com \
    --cc=force@forcemz.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).