# Git 1.6.5-rc git clone unhandled exception using http protocol

12 messages from 2009-10-09 to 2009-10-13. Participants: eduard stefan, Tay Ray Chuan, Michael Wookey, Johannes Sixt, Junio C Hamano.
Thread: https://gitlist.dev/t/21172

## eduard stefan, 2009-10-09 17:27

Subject: Git 1.6.5-rc git clone unhandled exception using http protocol
Message-ID: <4ACF7296.3010809@gmail.com>
URL: https://gitlist.dev/e/4ACF7296.3010809%40gmail.com

```
I've tried Git 1.6.5 release candidates (rc1, rc2, rc3) with msysGit,
and "git clone git://github.com/loudej/spark.git" it's working,
but "git clone http://github.com/loudej/spark.git" crashes
with an Win32 unhandled exception.
  I have tried to create an empty repository and run both
"git remote-curl http://github.com/loudej/spark.git"
and "git remote-curl" , but it crashes with the same error.
  How can I obtain more information about the error?

BTW, Git 1.6.4.4 is working over both protocols,
on Windows Server 2008 SP2 x86, using the same msysGit
(msysGit-fullinstall-1.6.4-preview20090729.exe).

Have a nice day,
  A.

```

## Tay Ray Chuan, 2009-10-10 10:55

Subject: Re: Git 1.6.5-rc git clone unhandled exception using http protocol
Message-ID: <be6fef0d0910100355v41de0771m30c153f413a46d2e@mail.gmail.com>
URL: https://gitlist.dev/e/be6fef0d0910100355v41de0771m30c153f413a46d2e%40mail.gmail.com
In-Reply-To: <4ACF7296.3010809@gmail.com>

```
Hi,

On Sat, Oct 10, 2009 at 1:27 AM, eduard stefan <eduard.stefan@gmail.com> wrote:
>  How can I obtain more information about the error?

How are you executing the git commands? From the windows command line?
From the msys bash shell? Could you copy and paste the output of git
when cloning the repo?

How about the win32 exception? What does it say? Does it display as a dialog?
-- 
Cheers,
Ray Chuan

```

## eduard stefan, 2009-10-10 15:55

Subject: Re: Git 1.6.5-rc git clone unhandled exception using http protocol
Message-ID: <4AD0AE84.1070500@gmail.com>
URL: https://gitlist.dev/e/4AD0AE84.1070500%40gmail.com
In-Reply-To: <be6fef0d0910100811l325d3df1jdf8d3d9dd51e3385@mail.gmail.com>

```
Tay Ray Chuan wrote:
> Hi,
> 
> On Sat, Oct 10, 2009 at 10:51 PM, eduard stefan <eduard.stefan@gmail.com> wrote:
>> I attached three screenshots of the msys shell,
>> it doesn't matter what url is used,
>> and git remote-curl doesn't crash when run in a non-git repository,
>> but as soon as I create an empty repo, it crashes just like git clone http://...
> 
> that's not how you use remote-curl.
> 
> Cloning a bogus repository (http://test.com/sample.git) isn't a good idea too.

I was just trying to point that the URL used is not relevant,
as long as the protocol used is URL, then it crashes.

> Could you show me the screenshot of you cloning
> http://github.com/loudej/spark.git?

Done.

Have a nice day,
  A.


```

## Tay Ray Chuan, 2009-10-10 16:07

Subject: Re: Git 1.6.5-rc git clone unhandled exception using http protocol
Message-ID: <be6fef0d0910100907t61ea922bqf117e6c025e94ce7@mail.gmail.com>
URL: https://gitlist.dev/e/be6fef0d0910100907t61ea922bqf117e6c025e94ce7%40mail.gmail.com
In-Reply-To: <4AD0AE84.1070500@gmail.com>

```
Hi,

On Sat, Oct 10, 2009 at 11:55 PM, eduard stefan <eduard.stefan@gmail.com> wrote:
> I was just trying to point that the URL used is not relevant,
> as long as the protocol used is URL, then it crashes.

ok.

I suspect, as you do, it's got to do with remote-curl.

Could you try this command?

  echo list | git remote-curl http://github.com/loudej/spark.git

On my machine, I get

  @refs/heads/master HEAD
  f192d3de483f2e7f38eebf84c8f1bbc8c4b5f185 refs/heads/gh-pages
  2a0cd31d8706ec2d8cc5d7b49873cc24621b20af refs/heads/installers
  10526926014eb2d89c2b449f1e29f4df7ab620bd refs/heads/master
  7f36b2caf2f01566bd58f9304d6ad5c36ae280ce refs/heads/mono
  80fc2424ebf082265c66bd6e0637c74744742b49 refs/heads/spark-1.1
  62d62d5c183dd22cdf9491999291047add05c722 refs/heads/spike-1.1
  d85abb61563e7f4f372c7e0418da0f20c49baf48 refs/tags/v1.0.39890-RC1
  db9d3380c39284695added69edab46c2ddab2f48 refs/tags/v1.0.39917-RC2
  70c418dd806a4eb7f32fa6fe710c9a5967ddef32 refs/tags/v1.0.39935


-- 
Cheers,
Ray Chuan

```

## eduard stefan, 2009-10-10 16:52

Subject: Re: Git 1.6.5-rc git clone unhandled exception using http protocol
Message-ID: <4AD0BBCB.8000306@gmail.com>
URL: https://gitlist.dev/e/4AD0BBCB.8000306%40gmail.com
In-Reply-To: <be6fef0d0910100907t61ea922bqf117e6c025e94ce7@mail.gmail.com>

```
Tay Ray Chuan wrote:
> I suspect, as you do, it's got to do with remote-curl.
> 
> Could you try this command?
> 
>   echo list | git remote-curl http://github.com/loudej/spark.git

Inside an empty repository it crashes the same way,
without any additional information.
"git remote-curl" crashes in the same way,
but "git remote-curl --help" tries to launch the browser.

Is there any way to obtain more information from this crash?
Some debug mode?

Have a nice day,
  A.

```

## Tay Ray Chuan, 2009-10-10 22:54

Subject: Re: Git 1.6.5-rc git clone unhandled exception using http protocol
Message-ID: <be6fef0d0910101554p53d5532cp17768d2c95e9dbf@mail.gmail.com>
URL: https://gitlist.dev/e/be6fef0d0910101554p53d5532cp17768d2c95e9dbf%40mail.gmail.com
In-Reply-To: <4AD0BBCB.8000306@gmail.com>

```
Hi,

On Sun, Oct 11, 2009 at 12:52 AM, eduard stefan <eduard.stefan@gmail.com> wrote:
> Tay Ray Chuan wrote:
>> I suspect, as you do, it's got to do with remote-curl.
>>
>> Could you try this command?
>>
>>   echo list | git remote-curl http://github.com/loudej/spark.git
>
> Inside an empty repository it crashes the same way,
> without any additional information.
> "git remote-curl" crashes in the same way,
> but "git remote-curl --help" tries to launch the browser.

just to check, running

  echo list | git remote-curl http://github.com/loudej/spark.git

and

  git clone http://github.com/loudej/spark.git

both gives the same error message:

  An unhandled win32 exception occurred in git-remote-curl.exe [5820].
  Just-In-Time debugging this exception failed with the following
  error: No installed debugger has Just-In-Time debugging enabled. In
  Visual Studio, Just-In-Time debugging can be enabled from
  Tools/Options/Debugging/Just-In-Time.

  Check the documentation index for 'Just-in-time debugging, errors'
  for more information.

in a dialog?

> Is there any way to obtain more information from this crash?
> Some debug mode?

I'm assuming you're using the Microsoft Visual Studio development
tools to compile git from the source. I'm cc'ing this to the msysgit
mailing list, perhaps someone familiar with them can advise you
further.

-- 
Cheers,
Ray Chuan

```

## eduard stefan, 2009-10-11 21:12

Subject: Re: Git 1.6.5-rc git clone unhandled exception using http protocol
Message-ID: <4AD24A46.5020705@gmail.com>
URL: https://gitlist.dev/e/4AD24A46.5020705%40gmail.com
In-Reply-To: <be6fef0d0910101554p53d5532cp17768d2c95e9dbf@mail.gmail.com>

```
Tay Ray Chuan wrote:

> just to check, running
> 
>   echo list | git remote-curl http://github.com/loudej/spark.git
> 
> and
> 
>   git clone http://github.com/loudej/spark.git
> 
> both gives the same error message:
> 
>   An unhandled win32 exception occurred in git-remote-curl.exe [5820].
>   Just-In-Time debugging this exception failed with the following
>   error: No installed debugger has Just-In-Time debugging enabled. In
>   Visual Studio, Just-In-Time debugging can be enabled from
>   Tools/Options/Debugging/Just-In-Time.
> 
>   Check the documentation index for 'Just-in-time debugging, errors'
>   for more information.
> 
> in a dialog?
> 
>> Is there any way to obtain more information from this crash?
>> Some debug mode?
> 
> I'm assuming you're using the Microsoft Visual Studio development
> tools to compile git from the source. I'm cc'ing this to the msysgit
> mailing list, perhaps someone familiar with them can advise you
> further.
> 

Git was compiled with msysGit, the errors are generated inside msysGit shell,
and VS2008 debugger gives this message:

"Unhandled exception at 0x00420354 in git-remote-curl.exe:
 0xC0000005: Access violation reading location 0x00000000."

Have a nice day,
  Eduard

```

## eduard stefan, 2009-10-13 03:36

Subject: Re: Git 1.6.5 git clone unhandled exception using http protocol
Message-ID: <4AD3F5BB.1050308@gmail.com>
URL: https://gitlist.dev/e/4AD3F5BB.1050308%40gmail.com
In-Reply-To: <4AD24A46.5020705@gmail.com>

```
> Git was compiled with msysGit, the errors are generated inside msysGit shell,
> and VS2008 debugger gives this message:
> 
> "Unhandled exception at 0x00420354 in git-remote-curl.exe:
>  0xC0000005: Access violation reading location 0x00000000."

As a sidenote, 1.6.5 release crashes the same way.

After applying Shawn O. Pearce "Return of smart HTTP" patch series,
it no longer crashes, and "git clone http://github.com/loudej/spark.git" returns
"error: Unable to get pack file
http://github.com/loudej/spark.git/objects/pack/
pack-1bc121e71e2847622f814603ddb34444bfc6a16c.pack
The requested URL returned error: 502"
which seems to be more like a GitHub problem.

OTOH, cloning a local repositor serverd with mongoose works as expected:
"git clone http://192.168.194.24/test.git/"

Have a nice day,
  Eduard

```

## Michael Wookey, 2009-10-13 10:10

Subject: Re: Git 1.6.5-rc git clone unhandled exception using http protocol
Message-ID: <d2e97e800910130310wa9731a6j9b9bdd25047ade85@mail.gmail.com>
URL: https://gitlist.dev/e/d2e97e800910130310wa9731a6j9b9bdd25047ade85%40mail.gmail.com
In-Reply-To: <4AD0BBCB.8000306@gmail.com>

```
2009/10/11 eduard stefan <eduard.stefan@gmail.com>:
> Tay Ray Chuan wrote:
>> I suspect, as you do, it's got to do with remote-curl.
>>
>> Could you try this command?
>>
>>   echo list | git remote-curl http://github.com/loudej/spark.git
>
> Inside an empty repository it crashes the same way,
> without any additional information.
> "git remote-curl" crashes in the same way,
> but "git remote-curl --help" tries to launch the browser.
>
> Is there any way to obtain more information from this crash?
> Some debug mode?

Using the above repository, I see the same crash with msysGit at git
revision 1.6.5. Using windbg as the post-mortem debugger, the
following information is captured:

  (a14.e8c): Access violation - code c0000005 (!!! second chance !!!)
  eax=00000000 ebx=00000000 ecx=ffffffff edx=0046cc00 esi=0046f98f edi=00000000
  eip=00420354 esp=0022fd80 ebp=0022fda8 iopl=0         nv up ei pl zr na pe nc
  cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246

...and the faulting instruction is:

  git_remote_curl+0x20354:
  00420354 f2ae            repne scas byte ptr es:[edi]

so, a NULL dereference. The initial disassembly of the function is this:

  0:000> u 0042033C
  git_remote_curl+0x2033c:
  0042033c 55              push    ebp
  0042033d 89e5            mov     ebp,esp
  0042033f 57              push    edi
  00420340 56              push    esi
  00420341 53              push    ebx
  00420342 83ec1c          sub     esp,1Ch
  00420345 8b5d08          mov     ebx,dword ptr [ebp+8]
  00420348 8b750c          mov     esi,dword ptr [ebp+0Ch]
  0042034b 31c0            xor     eax,eax
  0042034d b9ffffffff      mov     ecx,0FFFFFFFFh
  00420352 89df            mov     edi,ebx
  00420354 f2ae            repne scas byte ptr es:[edi]
  00420356 f7d1            not     ecx
  00420358 8d51ff          lea     edx,[ecx-1]
  0042035b b9ffffffff      mov     ecx,0FFFFFFFFh
  00420360 89f7            mov     edi,esi
  00420362 f2ae            repne scas byte ptr es:[edi]
  00420364 f7d1            not     ecx
  00420366 49              dec     ecx
  00420367 7466            je      git_remote_curl+0x203cf (004203cf)
  00420369 85d2            test    edx,edx
  0042036b 0f84b1000000    je      git_remote_curl+0x20422 (00420422)
  00420371 89f7            mov     edi,esi
  00420373 89de            mov     esi,ebx
  ...

So its the first parameter that is NULL. The second parameter is:

  0:000> da poi(ebp+c)
  0046f98f  "libexec/git-core"

I don't know how to build msysGit so that symbols are generated so
I've attempted to reconstruct the source code; which ends up looking
something like the following:

  int some_unknown_func(char *arg1, char *arg2)
  {
      len1 = strlen(arg1) - 1;  // <- crash here
      len2 = strlen(arg2);
      len3 = len2 - 1;

      if (len2 != 1) {
          if (!len1)
              return 0;
          for (;;) {
              x = arg1[len1 - 1];

              if (x != '/' && x != '\\') {
                  --len1;
                  --len3;
                  if (arg1[len1] != arg2[len3])
                      return 0;
              } else {
                  ...
              }
          }
      }
  }

Perhaps those more familiar with git's sources might recognise code
that looks similar to the above sequence.

```

## Johannes Sixt, 2009-10-13 10:53

Subject: Re: Git 1.6.5-rc git clone unhandled exception using http protocol
Message-ID: <4AD45C28.4080501@viscovery.net>
URL: https://gitlist.dev/e/4AD45C28.4080501%40viscovery.net
In-Reply-To: <d2e97e800910130310wa9731a6j9b9bdd25047ade85@mail.gmail.com>

```

Michael Wookey schrieb:
> Using the above repository, I see the same crash with msysGit at git
> revision 1.6.5. Using windbg as the post-mortem debugger, the
> following information is captured:
> 
>   (a14.e8c): Access violation - code c0000005 (!!! second chance !!!)
>   eax=00000000 ebx=00000000 ecx=ffffffff edx=0046cc00 esi=0046f98f edi=00000000
>   eip=00420354 esp=0022fd80 ebp=0022fda8 iopl=0         nv up ei pl zr na pe nc
>   cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246
> 
> ...and the faulting instruction is:
> 
>   git_remote_curl+0x20354:
>   00420354 f2ae            repne scas byte ptr es:[edi]
> 
> so, a NULL dereference. The initial disassembly of the function is this:
> 
>   0:000> u 0042033C
>   git_remote_curl+0x2033c:
>   0042033c 55              push    ebp
>   0042033d 89e5            mov     ebp,esp
>   0042033f 57              push    edi
>   00420340 56              push    esi
>   00420341 53              push    ebx
>   00420342 83ec1c          sub     esp,1Ch
>   00420345 8b5d08          mov     ebx,dword ptr [ebp+8]
>   00420348 8b750c          mov     esi,dword ptr [ebp+0Ch]
>   0042034b 31c0            xor     eax,eax
>   0042034d b9ffffffff      mov     ecx,0FFFFFFFFh
>   00420352 89df            mov     edi,ebx
>   00420354 f2ae            repne scas byte ptr es:[edi]
>   00420356 f7d1            not     ecx
>   00420358 8d51ff          lea     edx,[ecx-1]
>   0042035b b9ffffffff      mov     ecx,0FFFFFFFFh
>   00420360 89f7            mov     edi,esi
>   00420362 f2ae            repne scas byte ptr es:[edi]
>   00420364 f7d1            not     ecx
>   00420366 49              dec     ecx
>   00420367 7466            je      git_remote_curl+0x203cf (004203cf)
>   00420369 85d2            test    edx,edx
>   0042036b 0f84b1000000    je      git_remote_curl+0x20422 (00420422)
>   00420371 89f7            mov     edi,esi
>   00420373 89de            mov     esi,ebx
>   ...
> 
> So its the first parameter that is NULL. The second parameter is:
> 
>   0:000> da poi(ebp+c)
>   0046f98f  "libexec/git-core"
> 
> I don't know how to build msysGit so that symbols are generated so
> I've attempted to reconstruct the source code; which ends up looking
> something like the following:
> 
>   int some_unknown_func(char *arg1, char *arg2)
>   {
>       len1 = strlen(arg1) - 1;  // <- crash here
>       len2 = strlen(arg2);
>       len3 = len2 - 1;
> 
>       if (len2 != 1) {
>           if (!len1)
>               return 0;
>           for (;;) {
>               x = arg1[len1 - 1];
> 
>               if (x != '/' && x != '\\') {
>                   --len1;
>                   --len3;
>                   if (arg1[len1] != arg2[len3])
>                       return 0;
>               } else {
>                   ...
>               }
>           }
>       }
>   }
> 
> Perhaps those more familiar with git's sources might recognise code
> that looks similar to the above sequence.

Wow, this is great work, thank you very much! The function is
strip_path_suffix(). And here is a patch that fixes the crash.

--- >8 ---
From: Johannes Sixt <j6t@kdbg.org>
Subject: [PATCH] remote-curl: add missing initialization of argv0_path

All programs, in particular also the stand-alone programs (non-builtins)
must call git_extract_argv0_path(argv[0]) in order to help builds that
derive the installation prefix at runtime, such as the MinGW build.
Without this call, the program segfaults (or raises an assertion
failure).

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 remote-curl.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/remote-curl.c b/remote-curl.c
index ad6a163..d8d276a 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -82,6 +82,7 @@ int main(int argc, const char **argv)
 	const char *url;
 	struct walker *walker = NULL;

+	git_extract_argv0_path(argv[0]);
 	setup_git_directory();
 	if (argc < 2) {
 		fprintf(stderr, "Remote needed\n");
-- 
1.6.5.1024.g31034.dirty

```

## Michael Wookey, 2009-10-13 11:43

Subject: Re: Git 1.6.5-rc git clone unhandled exception using http protocol
Message-ID: <d2e97e800910130443m56ea2850nf72274fc55a4be68@mail.gmail.com>
URL: https://gitlist.dev/e/d2e97e800910130443m56ea2850nf72274fc55a4be68%40mail.gmail.com
In-Reply-To: <4AD45C28.4080501@viscovery.net>

```

2009/10/13 Johannes Sixt <j.sixt@viscovery.net>:
> Michael Wookey schrieb:
>> Using the above repository, I see the same crash with msysGit at git
>> revision 1.6.5. Using windbg as the post-mortem debugger, the
>> following information is captured:
>> [ ... snip ... ]
> Wow, this is great work, thank you very much! The function is
> strip_path_suffix(). And here is a patch that fixes the crash.
>
> --- >8 ---
> From: Johannes Sixt <j6t@kdbg.org>
> Subject: [PATCH] remote-curl: add missing initialization of argv0_path
>
> All programs, in particular also the stand-alone programs (non-builtins)
> must call git_extract_argv0_path(argv[0]) in order to help builds that
> derive the installation prefix at runtime, such as the MinGW build.
> Without this call, the program segfaults (or raises an assertion
> failure).
>
> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
> ---
>  remote-curl.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/remote-curl.c b/remote-curl.c
> index ad6a163..d8d276a 100644
> --- a/remote-curl.c
> +++ b/remote-curl.c
> @@ -82,6 +82,7 @@ int main(int argc, const char **argv)
>        const char *url;
>        struct walker *walker = NULL;
>
> +       git_extract_argv0_path(argv[0]);
>        setup_git_directory();
>        if (argc < 2) {
>                fprintf(stderr, "Remote needed\n");
> --
> 1.6.5.1024.g31034.dirty

No more crashes for me :)

Tested-by: Michael Wookey <michaelwookey@gmail.com>

```

## Junio C Hamano, 2009-10-13 21:06

Subject: Re: Git 1.6.5-rc git clone unhandled exception using http protocol
Message-ID: <7v4oq3uhp2.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v4oq3uhp2.fsf%40alter.siamese.dyndns.org
In-Reply-To: <d2e97e800910130443m56ea2850nf72274fc55a4be68@mail.gmail.com>

```

Michael Wookey <michaelwookey@gmail.com> writes:

> 2009/10/13 Johannes Sixt <j.sixt@viscovery.net>:
>> Michael Wookey schrieb:
>>> Using the above repository, I see the same crash with msysGit at git
>>> revision 1.6.5. Using windbg as the post-mortem debugger, the
>>> following information is captured:
>>> [ ... snip ... ]
>> Wow, this is great work, thank you very much! The function is
>> strip_path_suffix(). And here is a patch that fixes the crash.
>>
>> --- >8 ---
>> From: Johannes Sixt <j6t@kdbg.org>
>> Subject: [PATCH] remote-curl: add missing initialization of argv0_path
>>
>> All programs, in particular also the stand-alone programs (non-builtins)
>> must call git_extract_argv0_path(argv[0]) in order to help builds that
>> derive the installation prefix at runtime, such as the MinGW build.
>> Without this call, the program segfaults (or raises an assertion
>> failure).
>>
>> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
>> ---
>>  remote-curl.c |    1 +
>>  1 files changed, 1 insertions(+), 0 deletions(-)
>>
>> diff --git a/remote-curl.c b/remote-curl.c
>> index ad6a163..d8d276a 100644
>> --- a/remote-curl.c
>> +++ b/remote-curl.c
>> @@ -82,6 +82,7 @@ int main(int argc, const char **argv)
>>        const char *url;
>>        struct walker *walker = NULL;
>>
>> +       git_extract_argv0_path(argv[0]);
>>        setup_git_directory();
>>        if (argc < 2) {
>>                fprintf(stderr, "Remote needed\n");
>> --
>> 1.6.5.1024.g31034.dirty
>
> No more crashes for me :)

Beautiful.  Thanks, both of you!

```
