# [PATCH] git-compat-util.h: reduce optimization level to 1 on MinGW env.

6 messages from 2013-09-25 to 2013-09-26. Participants: Wataru Noguchi, Jonathan Nieder, Johannes Schindelin.
Thread: https://gitlist.dev/t/35019

## Wataru Noguchi, 2013-09-25 15:45

Subject: [PATCH] git-compat-util.h: reduce optimization level to 1 on MinGW env.
Message-ID: <1380123941-25941-1-git-send-email-wnoguchi.0727@gmail.com>
URL: https://gitlist.dev/e/1380123941-25941-1-git-send-email-wnoguchi.0727%40gmail.com

```
Git for Windows crashes when clone Japanese multibyte repository.
- Japanese Base Encoding is Shift-JIS.
- It happens Japanese multibyte directory name and too-long directory path
- Linux(ex. Ubuntu 13.04 amd64) can clone normally.
- example repository is here:

git clone https://github.com/wnoguchi/mingw-checkout-crash.git

- The reproduce crash repository contains following file only.
  - following directory and file name is encoded for this commit log.
  - actually file name is decoded.]
  %E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%201-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%202-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%203-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%204-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%205-long-long-long-dirname/%E3%81%AF%E3%81%98%E3%82%81%E3%81%AB%E3%81%8A%E8%AA%AD%E3%81%BF%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84.txt
- only one commit.

This commit reduce gcc optimization level from O2 to O1 when MinGW Windows environment.

Signed-off-by: Wataru Noguchi <wnoguchi.0727@gmail.com>
---
 git-compat-util.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/git-compat-util.h b/git-compat-util.h
index a31127f..394c23b 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -90,6 +90,8 @@
 #define WIN32_LEAN_AND_MEAN  /* stops windows.h including winsock.h */
 #include <winsock2.h>
 #include <windows.h>
+/* reduce gcc optimization level to 1 */
+#pragma GCC optimize ("O1")
 #define GIT_WINDOWS_NATIVE
 #endif
 
-- 
1.8.1.2

```

## Jonathan Nieder, 2013-09-25 19:15

Subject: Re: [PATCH] git-compat-util.h: reduce optimization level to 1 on MinGW env.
Message-ID: <20130925191527.GY9464@google.com>
URL: https://gitlist.dev/e/20130925191527.GY9464%40google.com
In-Reply-To: <1380123941-25941-1-git-send-email-wnoguchi.0727@gmail.com>

```
(cc-ing the Git for Windows maintainers)
Hi,

Wataru Noguchi wrote:

> Git for Windows crashes when clone Japanese multibyte repository.
> - Japanese Base Encoding is Shift-JIS.
> - It happens Japanese multibyte directory name and too-long directory path
> - Linux(ex. Ubuntu 13.04 amd64) can clone normally.
> - example repository is here:
>
> git clone https://github.com/wnoguchi/mingw-checkout-crash.git
>
> - The reproduce crash repository contains following file only.
>   - following directory and file name is encoded for this commit log.
>   - actually file name is decoded.]
>   %E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%201-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%202-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%203-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%204-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%205-long-long-long-dirname/%E3%81%AF%E3%81%98%E3%82%81%E3%81%AB%E3%81%8A%E8%AA%AD%E3%81%BF%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84.txt
> - only one commit.
>
> This commit reduce gcc optimization level from O2 to O1 when MinGW Windows environment.
>
> Signed-off-by: Wataru Noguchi <wnoguchi.0727@gmail.com>

Thanks.

> ---
>  git-compat-util.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/git-compat-util.h b/git-compat-util.h
> index a31127f..394c23b 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -90,6 +90,8 @@
>  #define WIN32_LEAN_AND_MEAN  /* stops windows.h including winsock.h */
>  #include <winsock2.h>
>  #include <windows.h>
> +/* reduce gcc optimization level to 1 */
> +#pragma GCC optimize ("O1")
>  #define GIT_WINDOWS_NATIVE
>  #endif

Do you know why reducing the optimization level avoids a crash?
Perhaps this is just masking the symptoms and the problem is still
lurking.

If changing the optimization level turns out to be the right fix, I
would prefer to see this change made in the Makefile instead of
git-compat-util.h.  That way, the user building can still easily
override the optimization settings to -O0 if they want to during a
debugging session.

What do you think?

Hope that helps,
Jonathan

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

```

## Johannes Schindelin, 2013-09-25 19:50

Subject: Re: Re: [PATCH] git-compat-util.h: reduce optimization level to 1 on MinGW env.
Message-ID: <alpine.DEB.1.00.1309252142220.1191@s15462909.onlinehome-server.info>
URL: https://gitlist.dev/e/alpine.DEB.1.00.1309252142220.1191%40s15462909.onlinehome-server.info
In-Reply-To: <20130925191527.GY9464@google.com>

```
Hi,

On Wed, 25 Sep 2013, Jonathan Nieder wrote:

> Wataru Noguchi wrote:
> 
> >   - actually file name is decoded.]
> >   %E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%201-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%202-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%203-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%204-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%205-long-long-long-dirname/%E3%81%AF%E3%81%98%E3%82%81%E3%81%AB%E3%81%8A%E8%AA%AD%E3%81%BF%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84.txt
> >
> > This commit reduce gcc optimization level from O2 to O1 when MinGW
> > Windows environment.
> 
> Do you know why reducing the optimization level avoids a crash?

I suspect that the optimization level causes smaller (or no) buffer bytes
between data structures and the crash is the symptom of a buffer overflow.
In that light, I think that reducing the optimization level is most likely
just working around this particular issue, and other scenarios might still
crash until we fix the underlying bug.

Most likely the problem is with our Windows-specific UTF-8 handling, I
would not be surprised if it is my "favorite" bug: an off-by-one.

To find out what the real cause is, I suggest using a tool similar to
valgrind. Valgrind does not run on Windows, but I DuckDuckWent e.g.
http://code.google.com/p/drmemory/ as an alternative that could be tried
to identify the problem.

Ciao,
Johannes

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

```

## Wataru Noguchi, 2013-09-25 23:42

Subject: Re: Re: [PATCH] git-compat-util.h: reduce optimization level to 1 on MinGW env.
Message-ID: <CAFRcQ0FohRz+eKsq=c8S2JGHb-_2sZaApNJwY6-ey2_jF3qmJg@mail.gmail.com>
URL: https://gitlist.dev/e/CAFRcQ0FohRz%2BeKsq%3Dc8S2JGHb-_2sZaApNJwY6-ey2_jF3qmJg%40mail.gmail.com
In-Reply-To: <alpine.DEB.1.00.1309252142220.1191@s15462909.onlinehome-server.info>

```
Hi,

Thanks for your reply.

> If changing the optimization level turns out to be the right fix, I
> would prefer to see this change made in the Makefile instead of
> git-compat-util.h.

Yes, I see.
I think so.
I shuld write optimization level change code to Makefile instead of
git-compat-util.h.


2013/9/26 Jonathan Nieder <jrnieder@gmail.com>

> (cc-ing the Git for Windows maintainers)
> Hi,
>
> Wataru Noguchi wrote:
>
> > Git for Windows crashes when clone Japanese multibyte repository.
> > - Japanese Base Encoding is Shift-JIS.
> > - It happens Japanese multibyte directory name and too-long directory
> path
> > - Linux(ex. Ubuntu 13.04 amd64) can clone normally.
> > - example repository is here:
> >
> > git clone https://github.com/wnoguchi/mingw-checkout-crash.git
> >
> > - The reproduce crash repository contains following file only.
> >   - following directory and file name is encoded for this commit log.
> >   - actually file name is decoded.]
> >
> %E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%201-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%202-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%203-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%204-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%205-long-long-long-dirname/%E3%81%AF%E3%81%98%E3%82%81%E3%81%AB%E3%81%8A%E8%AA%AD%E3%81%BF%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84.txt
> > - only one commit.
> >
> > This commit reduce gcc optimization level from O2 to O1 when MinGW
> Windows environment.
> >
> > Signed-off-by: Wataru Noguchi <wnoguchi.0727@gmail.com>
>
> Thanks.
>
> > ---
> >  git-compat-util.h | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/git-compat-util.h b/git-compat-util.h
> > index a31127f..394c23b 100644
> > --- a/git-compat-util.h
> > +++ b/git-compat-util.h
> > @@ -90,6 +90,8 @@
> >  #define WIN32_LEAN_AND_MEAN  /* stops windows.h including winsock.h */
> >  #include <winsock2.h>
> >  #include <windows.h>
> > +/* reduce gcc optimization level to 1 */
> > +#pragma GCC optimize ("O1")
> >  #define GIT_WINDOWS_NATIVE
> >  #endif
>
> Do you know why reducing the optimization level avoids a crash?
> Perhaps this is just masking the symptoms and the problem is still
> lurking.
>
> If changing the optimization level turns out to be the right fix, I
> would prefer to see this change made in the Makefile instead of
> git-compat-util.h.  That way, the user building can still easily
> override the optimization settings to -O0 if they want to during a
> debugging session.
>
> What do you think?
>
> Hope that helps,
> Jonathan
>

Hi,

Thanks for your advise.

> To find out what the real cause is, I suggest using a tool similar to
> valgrind. Valgrind does not run on Windows, but I DuckDuckWent e.g.
> http://code.google.com/p/drmemory/ as an alternative that could be tried
> to identify the problem.

I will try debugging by using any tools more real cause.
* Valgrind and drmemory, etc.

2013/9/26 Johannes Schindelin <Johannes.Schindelin@gmx.de>

> Hi,
>
> On Wed, 25 Sep 2013, Jonathan Nieder wrote:
>
> > Wataru Noguchi wrote:
> >
> > >   - actually file name is decoded.]
> > >
> %E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%201-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%202-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%203-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%204-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%205-long-long-long-dirname/%E3%81%AF%E3%81%98%E3%82%81%E3%81%AB%E3%81%8A%E8%AA%AD%E3%81%BF%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84.txt
> > >
> > > This commit reduce gcc optimization level from O2 to O1 when MinGW
> > > Windows environment.
> >
> > Do you know why reducing the optimization level avoids a crash?
>
> I suspect that the optimization level causes smaller (or no) buffer bytes
> between data structures and the crash is the symptom of a buffer overflow.
> In that light, I think that reducing the optimization level is most likely
> just working around this particular issue, and other scenarios might still
> crash until we fix the underlying bug.
>
> Most likely the problem is with our Windows-specific UTF-8 handling, I
> would not be surprised if it is my "favorite" bug: an off-by-one.
>
> To find out what the real cause is, I suggest using a tool similar to
> valgrind. Valgrind does not run on Windows, but I DuckDuckWent e.g.
> http://code.google.com/p/drmemory/ as an alternative that could be tried
> to identify the problem.
>
> Ciao,
> Johannes
>


Thanks!

-- 
===========================
  Wataru Noguchi
  wnoguchi.0727@gmail.com
  http://wnoguchi.github.io/
===========================

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

```

## Wataru Noguchi, 2013-09-25 23:46

Subject: Re: [PATCH] git-compat-util.h: reduce optimization level to 1 on MinGW env.
Message-ID: <CAFRcQ0HPnnBFE7ww38OBO78SbHTJZpdPn4zd26k5TeUXWbGMGg@mail.gmail.com>
URL: https://gitlist.dev/e/CAFRcQ0HPnnBFE7ww38OBO78SbHTJZpdPn4zd26k5TeUXWbGMGg%40mail.gmail.com
In-Reply-To: <20130925191527.GY9464@google.com>

```
Hi,

Thanks for your reply and advise.

> If changing the optimization level turns out to be the right fix, I
> would prefer to see this change made in the Makefile instead of
> git-compat-util.h.

Yes, I see.
I think so.
I shuld write optimization level change code to Makefile instead of
git-compat-util.h.


2013/9/26 Jonathan Nieder <jrnieder@gmail.com>

> (cc-ing the Git for Windows maintainers)
> Hi,
>
> Wataru Noguchi wrote:
>
> > Git for Windows crashes when clone Japanese multibyte repository.
> > - Japanese Base Encoding is Shift-JIS.
> > - It happens Japanese multibyte directory name and too-long directory
> path
> > - Linux(ex. Ubuntu 13.04 amd64) can clone normally.
> > - example repository is here:
> >
> > git clone https://github.com/wnoguchi/mingw-checkout-crash.git
> >
> > - The reproduce crash repository contains following file only.
> >   - following directory and file name is encoded for this commit log.
> >   - actually file name is decoded.]
> >
> %E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%201-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%202-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%203-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%204-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%205-long-long-long-dirname/%E3%81%AF%E3%81%98%E3%82%81%E3%81%AB%E3%81%8A%E8%AA%AD%E3%81%BF%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84.txt
> > - only one commit.
> >
> > This commit reduce gcc optimization level from O2 to O1 when MinGW
> Windows environment.
> >
> > Signed-off-by: Wataru Noguchi <wnoguchi.0727@gmail.com>
>
> Thanks.
>
> > ---
> >  git-compat-util.h | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/git-compat-util.h b/git-compat-util.h
> > index a31127f..394c23b 100644
> > --- a/git-compat-util.h
> > +++ b/git-compat-util.h
> > @@ -90,6 +90,8 @@
> >  #define WIN32_LEAN_AND_MEAN  /* stops windows.h including winsock.h */
> >  #include <winsock2.h>
> >  #include <windows.h>
> > +/* reduce gcc optimization level to 1 */
> > +#pragma GCC optimize ("O1")
> >  #define GIT_WINDOWS_NATIVE
> >  #endif
>
> Do you know why reducing the optimization level avoids a crash?
> Perhaps this is just masking the symptoms and the problem is still
> lurking.
>
> If changing the optimization level turns out to be the right fix, I
> would prefer to see this change made in the Makefile instead of
> git-compat-util.h.  That way, the user building can still easily
> override the optimization settings to -O0 if they want to during a
> debugging session.
>
> What do you think?
>
> Hope that helps,
> Jonathan
>

Thanks.


-- 
===========================
  Wataru Noguchi
  wnoguchi.0727@gmail.com
  http://wnoguchi.github.io/
===========================

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

```

## Wataru Noguchi, 2013-09-26 00:47

Subject: Re: Re: [PATCH] git-compat-util.h: reduce optimization level to 1 on MinGW env.
Message-ID: <CAFRcQ0Fzikruv9tM5--hK9ELHZHDHQCcYyXxH7S9Xwv2p7_REg@mail.gmail.com>
URL: https://gitlist.dev/e/CAFRcQ0Fzikruv9tM5--hK9ELHZHDHQCcYyXxH7S9Xwv2p7_REg%40mail.gmail.com
In-Reply-To: <alpine.DEB.1.00.1309252142220.1191@s15462909.onlinehome-server.info>

```
Hi,

I'm sorry resend email many times...
My GMail setting default to HTML format.
So mail sent to Git ML is rejected...

----------------------------
Thanks for your reply.

> If changing the optimization level turns out to be the right fix, I
> would prefer to see this change made in the Makefile instead of
> git-compat-util.h.

Yes, I see.
I think so.
I shuld write optimization level change code to Makefile instead of
git-compat-util.h.



2013/9/26 Jonathan Nieder <jrnieder@gmail.com>:
> (cc-ing the Git for Windows maintainers)
> Hi,
>
> Wataru Noguchi wrote:
>
>> Git for Windows crashes when clone Japanese multibyte repository.
>> - Japanese Base Encoding is Shift-JIS.
>> - It happens Japanese multibyte directory name and too-long directory path
>> - Linux(ex. Ubuntu 13.04 amd64) can clone normally.
>> - example repository is here:
>>
>> git clone https://github.com/wnoguchi/mingw-checkout-crash.git
>>
>> - The reproduce crash repository contains following file only.
>>   - following directory and file name is encoded for this commit log.
>>   - actually file name is decoded.]
>>   %E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%201-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%202-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%203-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%204-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%205-long-long-long-dirname/%E3%81%AF%E3%81%98%E3%82%81%E3%81%AB%E3%81%8A%E8%AA%AD%E3%81%BF%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84.txt
>> - only one commit.
>>
>> This commit reduce gcc optimization level from O2 to O1 when MinGW Windows environment.
>>
>> Signed-off-by: Wataru Noguchi <wnoguchi.0727@gmail.com>
>
> Thanks.
>
>> ---
>>  git-compat-util.h | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/git-compat-util.h b/git-compat-util.h
>> index a31127f..394c23b 100644
>> --- a/git-compat-util.h
>> +++ b/git-compat-util.h
>> @@ -90,6 +90,8 @@
>>  #define WIN32_LEAN_AND_MEAN  /* stops windows.h including winsock.h */
>>  #include <winsock2.h>
>>  #include <windows.h>
>> +/* reduce gcc optimization level to 1 */
>> +#pragma GCC optimize ("O1")
>>  #define GIT_WINDOWS_NATIVE
>>  #endif
>
> Do you know why reducing the optimization level avoids a crash?
> Perhaps this is just masking the symptoms and the problem is still
> lurking.
>
> If changing the optimization level turns out to be the right fix, I
> would prefer to see this change made in the Makefile instead of
> git-compat-util.h.  That way, the user building can still easily
> override the optimization settings to -O0 if they want to during a
> debugging session.
>
> What do you think?
>
> Hope that helps,
> Jonathan




Hi,

Thanks for your advise.

> To find out what the real cause is, I suggest using a tool similar to
> valgrind. Valgrind does not run on Windows, but I DuckDuckWent e.g.
> http://code.google.com/p/drmemory/ as an alternative that could be tried
> to identify the problem.

I will try debugging by using any tools more real cause.
* Valgrind and drmemory, etc.


2013/9/26 Johannes Schindelin <Johannes.Schindelin@gmx.de>:
> Hi,
>
> On Wed, 25 Sep 2013, Jonathan Nieder wrote:
>
>> Wataru Noguchi wrote:
>>
>> >   - actually file name is decoded.]
>> >   %E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%201-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%202-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%203-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%204-long-long-long-dirname/%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%205-long-long-long-dirname/%E3%81%AF%E3%81%98%E3%82%81%E3%81%AB%E3%81%8A%E8%AA%AD%E3%81%BF%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84.txt
>> >
>> > This commit reduce gcc optimization level from O2 to O1 when MinGW
>> > Windows environment.
>>
>> Do you know why reducing the optimization level avoids a crash?
>
> I suspect that the optimization level causes smaller (or no) buffer bytes
> between data structures and the crash is the symptom of a buffer overflow.
> In that light, I think that reducing the optimization level is most likely
> just working around this particular issue, and other scenarios might still
> crash until we fix the underlying bug.
>
> Most likely the problem is with our Windows-specific UTF-8 handling, I
> would not be surprised if it is my "favorite" bug: an off-by-one.
>
> To find out what the real cause is, I suggest using a tool similar to
> valgrind. Valgrind does not run on Windows, but I DuckDuckWent e.g.
> http://code.google.com/p/drmemory/ as an alternative that could be tried
> to identify the problem.
>
> Ciao,
> Johannes


Thanks!


-- 
===========================
  Wataru Noguchi
  wnoguchi.0727@gmail.com
  http://wnoguchi.github.io/
===========================

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

```
