* A little mystery - crash caused by empty commit message.
@ 2009-02-10 11:15 Tor Arvid Lund
2009-02-10 11:32 ` Jeff King
0 siblings, 1 reply; 6+ messages in thread
From: Tor Arvid Lund @ 2009-02-10 11:15 UTC (permalink / raw)
To: Git mailing list
Hi, all.
So - I started noticing a problem where for instance "git log" or "git
branch -av" would crash in one of my repositories. My environment is
Windows Vista x64, using msysgit. I have compiled several versions of
git, but I think I had version 1.6.0.3 then this problem arose. When
the crash occurred, Windows would just pop up a dialog window saying
"git.exe has stopped working". So I tried running it with gdb, which
told me there was a segfault in strchr() but no more. Git is built
with debug symbols (-g), so I am guessing this may be a problem with
my msysgit environment (maybe in conjunction with 64-bit Vista) or
something. But I don't really know what I'm talking about, and it is
another topic anyway...
Then I tried copying the repository to a linux box and tried gdb
there. Much better. strchr(line, '\n') is called in pretty.c in the
get_header function. For one of the commits, the 'line' parameter was
NULL, so I managed to make it not crash with this little patch:
diff --git a/pretty.c b/pretty.c
index 8d4dbc9..1b2d097 100644
--- a/pretty.c
+++ b/pretty.c
@@ -230,6 +230,8 @@ static char *get_header(const struct commit
*commit, const char *key)
const char *line = commit->buffer;
for (;;) {
+ if (line == NULL)
+ return NULL;
const char *eol = strchr(line, '\n'), *next;
if (line == eol)
The result from "git log" for me is then:
...
commit 6a1ac5bc05b2cdd276c7f8a39565681f9d8017d7
<normal output>
commit f67f77edf06bbcebabf430735c751245a4b70f14
Author: Tor Arvid Lund <toral@qsystems.no>
Date: Thu Feb 5 17:47:09 2009 +0100
commit 6d109492008c68d28af821b96b82f807f338caf6
<normal output>
...
That is - a handful of commits that are output "normally", followed by
one commit where the message is just blank, and then more "normal"
output... By the way - I tried running git fsck --full --strict, and
it did not report any errors (just the "common" list of dangling blobs
and such...
But the question is then - how did I manage to get my repository in
this state? The commit in question was made by me - I know I entered a
message when I committed it. I can even find the commit *with* the
original commit message in another branch... I am sorry to say that my
memory fails me, so I cannot remember all the times I may have moved
commits around, rebased, etc. I do such things often, as I use git-p4
to communicate with the "official company repo" (and because its so
nice :)). I don't know the core git code well, but when I'm in the
mood for speculation, I feel like a rebase or a cherry-pick must have
been the reason for this to have happened...
Well - I just thought I should tell you all about it. My simple little
patch makes it "not crash", but it should maybe report an error or
warning to the user - as something is most likely wrong somewhere.
-Tor Arvid-
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: A little mystery - crash caused by empty commit message.
2009-02-10 11:15 A little mystery - crash caused by empty commit message Tor Arvid Lund
@ 2009-02-10 11:32 ` Jeff King
2009-02-10 11:46 ` Johannes Sixt
2009-02-10 12:58 ` Tor Arvid Lund
0 siblings, 2 replies; 6+ messages in thread
From: Jeff King @ 2009-02-10 11:32 UTC (permalink / raw)
To: Tor Arvid Lund; +Cc: Git mailing list
On Tue, Feb 10, 2009 at 12:15:54PM +0100, Tor Arvid Lund wrote:
> Then I tried copying the repository to a linux box and tried gdb
> there. Much better. strchr(line, '\n') is called in pretty.c in the
> get_header function. For one of the commits, the 'line' parameter was
> NULL, so I managed to make it not crash with this little patch:
>
> diff --git a/pretty.c b/pretty.c
> index 8d4dbc9..1b2d097 100644
> --- a/pretty.c
> +++ b/pretty.c
> @@ -230,6 +230,8 @@ static char *get_header(const struct commit
> *commit, const char *key)
> const char *line = commit->buffer;
>
> for (;;) {
> + if (line == NULL)
> + return NULL;
> const char *eol = strchr(line, '\n'), *next;
>
> if (line == eol)
Hmm. I can't reproduce the crash here with an empty commit message. I
tried:
mkdir repo && cd repo && git init &&
touch file && git add . &&
tree=`git write-tree`
commit=`git commit-tree $tree </dev/null`
git update-ref HEAD $commit
git log
Are you sure it's truly an _empty_ commit message? Can you try
git cat-file commit f67f77edf06bbcebabf430735c751245a4b70f14
and look at the result with xxd, hd, or similar.
> But the question is then - how did I manage to get my repository in
> this state? The commit in question was made by me - I know I entered a
> message when I committed it. I can even find the commit *with* the
> original commit message in another branch... I am sorry to say that my
It _is_ generally hard to get an empty commit message using "git
commit". But it's possible there is a bug in cherry-pick, rebase, or
some ohter low-level tool that accidentally erased your message
as the commit was moved.
-Peff
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: A little mystery - crash caused by empty commit message.
2009-02-10 11:32 ` Jeff King
@ 2009-02-10 11:46 ` Johannes Sixt
2009-02-10 12:58 ` Tor Arvid Lund
1 sibling, 0 replies; 6+ messages in thread
From: Johannes Sixt @ 2009-02-10 11:46 UTC (permalink / raw)
To: Tor Arvid Lund; +Cc: Jeff King, Git mailing list
Jeff King schrieb:
> It _is_ generally hard to get an empty commit message using "git
> commit". But it's possible there is a bug in cherry-pick, rebase, or
> some ohter low-level tool that accidentally erased your message
> as the commit was moved.
Since this is on Windows, chances are that this is an encoding issue. If
you have non-ASCII in the commit message, but i18n.commitEncoding is
unset, then you can introduce invalid UTF8 sequences easily. This could
confuse one of the pipelines (rebase, am, cherry-pick, etc).
You should set
git config i18n.commitencoding cp1252
(or whatever is appropriate for you locale). I even have
git config i18n.logoutputencoding cp850
so that I see correct umlauts if I happen to run git log without a pager
in CMD ;) (I rarely do that, though.)
-- Hannes
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: A little mystery - crash caused by empty commit message.
2009-02-10 11:32 ` Jeff King
2009-02-10 11:46 ` Johannes Sixt
@ 2009-02-10 12:58 ` Tor Arvid Lund
2009-02-10 15:30 ` Jeff King
1 sibling, 1 reply; 6+ messages in thread
From: Tor Arvid Lund @ 2009-02-10 12:58 UTC (permalink / raw)
To: Jeff King; +Cc: Git mailing list
On Tue, Feb 10, 2009 at 12:32 PM, Jeff King <peff@peff.net> wrote:
> Are you sure it's truly an _empty_ commit message? Can you try
>
> git cat-file commit f67f77edf06bbcebabf430735c751245a4b70f14
>
> and look at the result with xxd, hd, or similar.
Cool. You are correct. It is not empty after all. I ran git cat-file
on that commit, and on the "same" commit on the branch where I did not
see the problem. The correct one looks like:
<start>
tree c5d2063a9b21de1f84240e4b9c0e40a44f0357b6
parent 6d109492008c68d28af821b96b82f807f338caf6
author Tor Arvid Lund <toral@qsystems.no> 1233852429 +0100
committer Tor Arvid Lund <toral@qsystems.no> 1233852429 +0100
[HIA] Log exception when serializing fails.
[git-p4: depot-paths = "//Heads/Dev/MarkII/Main/": change = 19233]
<stop>
So - after the "+0100" on the committer line, hd tells me (as
expected) that I have 0a 0a before "[HIA]". On the "faulty" commit I,
for some reason, have 0a 00 instead. I do not understand why, but I
guess strchr will return NULL when "\0[HIA]....." is passed to it, and
segfault on the next iteration.
So - I am no closer to understanding what got me to this state, but
your reply was helpful anyway, thanks :-)
-Tor Arvid-
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: A little mystery - crash caused by empty commit message.
2009-02-10 12:58 ` Tor Arvid Lund
@ 2009-02-10 15:30 ` Jeff King
2009-02-16 10:18 ` Tor Arvid Lund
0 siblings, 1 reply; 6+ messages in thread
From: Jeff King @ 2009-02-10 15:30 UTC (permalink / raw)
To: Tor Arvid Lund; +Cc: Git mailing list
On Tue, Feb 10, 2009 at 01:58:43PM +0100, Tor Arvid Lund wrote:
> So - after the "+0100" on the committer line, hd tells me (as
> expected) that I have 0a 0a before "[HIA]". On the "faulty" commit I,
> for some reason, have 0a 00 instead. I do not understand why, but I
> guess strchr will return NULL when "\0[HIA]....." is passed to it, and
> segfault on the next iteration.
>
> So - I am no closer to understanding what got me to this state, but
> your reply was helpful anyway, thanks :-)
Well, it certainly seems like a bug in one of the history-rewriting
programs. Can you try rebasing, cherry-picking, etc on the original
version of the commit to see if you can reproduce the breakage?
-Peff
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: A little mystery - crash caused by empty commit message.
2009-02-10 15:30 ` Jeff King
@ 2009-02-16 10:18 ` Tor Arvid Lund
0 siblings, 0 replies; 6+ messages in thread
From: Tor Arvid Lund @ 2009-02-16 10:18 UTC (permalink / raw)
To: Jeff King; +Cc: Git mailing list
On Tue, Feb 10, 2009 at 4:30 PM, Jeff King <peff@peff.net> wrote:
> On Tue, Feb 10, 2009 at 01:58:43PM +0100, Tor Arvid Lund wrote:
>
>> So - after the "+0100" on the committer line, hd tells me (as
>> expected) that I have 0a 0a before "[HIA]". On the "faulty" commit I,
>> for some reason, have 0a 00 instead. I do not understand why, but I
>> guess strchr will return NULL when "\0[HIA]....." is passed to it, and
>> segfault on the next iteration.
>>
>> So - I am no closer to understanding what got me to this state, but
>> your reply was helpful anyway, thanks :-)
>
> Well, it certainly seems like a bug in one of the history-rewriting
> programs. Can you try rebasing, cherry-picking, etc on the original
> version of the commit to see if you can reproduce the breakage?
Hi, I haven't had much time to test this thoroughly, but my primary
suspect is now git-p4 in conjunction with python v2.6, which I
recently installed. I will try to find some time to investigate
further, and let you all know for sure.
-Tor Arvid-
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-02-16 10:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-10 11:15 A little mystery - crash caused by empty commit message Tor Arvid Lund
2009-02-10 11:32 ` Jeff King
2009-02-10 11:46 ` Johannes Sixt
2009-02-10 12:58 ` Tor Arvid Lund
2009-02-10 15:30 ` Jeff King
2009-02-16 10:18 ` Tor Arvid Lund
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).