* 'git fast-export' is crashing on the gcc repo
@ 2007-12-11 20:27 Nicolas Pitre
2007-12-11 20:35 ` Marco Costalba
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Nicolas Pitre @ 2007-12-11 20:27 UTC (permalink / raw)
To: git
Simply doing something like:
$ git fast-export --all > /dev/null
results in:
fatal: Could not write blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
Since this is extremely enlightening, I patched it as follows:
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 2136aad..5c7bfe0 100755
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -104,7 +104,8 @@ static void handle_object(const unsigned char *sha1)
printf("blob\nmark :%d\ndata %lu\n", last_idnum, size);
if (fwrite(buf, size, 1, stdout) != 1)
- die ("Could not write blob %s", sha1_to_hex(sha1));
+ die ("Could not write blob %s: %s",
+ sha1_to_hex(sha1), strerror(errno));
printf("\n");
show_progress();
And then running it again produced:
fatal: Could not write blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391: Inappropriate ioctl for device
adding to today's confusion.
Nicolas
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: 'git fast-export' is crashing on the gcc repo
2007-12-11 20:27 'git fast-export' is crashing on the gcc repo Nicolas Pitre
@ 2007-12-11 20:35 ` Marco Costalba
2007-12-11 22:01 ` [PATCH] Fix git-fast-export for zero-sized blobs Alex Riesen
2007-12-11 22:06 ` 'git fast-export' is crashing on the gcc repo Nicolas Pitre
2 siblings, 0 replies; 10+ messages in thread
From: Marco Costalba @ 2007-12-11 20:35 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: git
On Dec 11, 2007 9:27 PM, Nicolas Pitre <nico@cam.org> wrote:
>
> And then running it again produced:
>
> fatal: Could not write blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391: Inappropriate ioctl for device
>
> adding to today's confusion.
>
GCC repo is turning out to be a very good test case indeed ;-)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] Fix git-fast-export for zero-sized blobs
2007-12-11 20:27 'git fast-export' is crashing on the gcc repo Nicolas Pitre
2007-12-11 20:35 ` Marco Costalba
@ 2007-12-11 22:01 ` Alex Riesen
2007-12-11 22:20 ` Nicolas Pitre
2007-12-11 22:06 ` 'git fast-export' is crashing on the gcc repo Nicolas Pitre
2 siblings, 1 reply; 10+ messages in thread
From: Alex Riesen @ 2007-12-11 22:01 UTC (permalink / raw)
To: git; +Cc: Nicolas Pitre, Johannes Schindelin, Junio C Hamano
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
builtin-fast-export.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
Nicolas Pitre, Tue, Dec 11, 2007 21:27:33 +0100:
> Simply doing something like:
>
> $ git fast-export --all > /dev/null
>
> results in:
>
> fatal: Could not write blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
>
I get this for my git repo:
$ git fast-export --all >/dev/null
fatal: Could not write blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
$ git cat-file blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 |wc -c
0
Writing a zero-size blob will surely returns 0.
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 2136aad..ef27eee 100755
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -103,7 +103,7 @@ static void handle_object(const unsigned char *sha1)
mark_object(object);
printf("blob\nmark :%d\ndata %lu\n", last_idnum, size);
- if (fwrite(buf, size, 1, stdout) != 1)
+ if (size && fwrite(buf, size, 1, stdout) != 1)
die ("Could not write blob %s", sha1_to_hex(sha1));
printf("\n");
--
1.5.3.7.1177.gb22b
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: 'git fast-export' is crashing on the gcc repo
2007-12-11 20:27 'git fast-export' is crashing on the gcc repo Nicolas Pitre
2007-12-11 20:35 ` Marco Costalba
2007-12-11 22:01 ` [PATCH] Fix git-fast-export for zero-sized blobs Alex Riesen
@ 2007-12-11 22:06 ` Nicolas Pitre
2007-12-12 1:38 ` Alex Riesen
2 siblings, 1 reply; 10+ messages in thread
From: Nicolas Pitre @ 2007-12-11 22:06 UTC (permalink / raw)
To: git
On Tue, 11 Dec 2007, Nicolas Pitre wrote:
> Simply doing something like:
>
> $ git fast-export --all > /dev/null
>
> results in:
>
> fatal: Could not write blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
>
> Since this is extremely enlightening, I patched it as follows:
>
> diff --git a/builtin-fast-export.c b/builtin-fast-export.c
> index 2136aad..5c7bfe0 100755
> --- a/builtin-fast-export.c
> +++ b/builtin-fast-export.c
> @@ -104,7 +104,8 @@ static void handle_object(const unsigned char *sha1)
>
> printf("blob\nmark :%d\ndata %lu\n", last_idnum, size);
> if (fwrite(buf, size, 1, stdout) != 1)
> - die ("Could not write blob %s", sha1_to_hex(sha1));
> + die ("Could not write blob %s: %s",
> + sha1_to_hex(sha1), strerror(errno));
> printf("\n");
>
> show_progress();
>
> And then running it again produced:
>
> fatal: Could not write blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391: Inappropriate ioctl for device
>
> adding to today's confusion.
Well, ignore the above. It seems that most of stdio doesn't set errno
so the above is crap.
Even strace doesn't show any error.
But, somehow, the following patch fixes it:
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 2136aad..c32a124 100755
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -103,7 +103,7 @@ static void handle_object(const unsigned char *sha1)
mark_object(object);
printf("blob\nmark :%d\ndata %lu\n", last_idnum, size);
- if (fwrite(buf, size, 1, stdout) != 1)
+ if (fwrite(buf, 1, size, stdout) != size)
die ("Could not write blob %s", sha1_to_hex(sha1));
printf("\n");
Go figure.
Nicolas
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] Fix git-fast-export for zero-sized blobs
2007-12-11 22:01 ` [PATCH] Fix git-fast-export for zero-sized blobs Alex Riesen
@ 2007-12-11 22:20 ` Nicolas Pitre
0 siblings, 0 replies; 10+ messages in thread
From: Nicolas Pitre @ 2007-12-11 22:20 UTC (permalink / raw)
To: Alex Riesen; +Cc: git, Johannes Schindelin, Junio C Hamano
On Tue, 11 Dec 2007, Alex Riesen wrote:
> Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
> ---
> builtin-fast-export.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> Nicolas Pitre, Tue, Dec 11, 2007 21:27:33 +0100:
> > Simply doing something like:
> >
> > $ git fast-export --all > /dev/null
> >
> > results in:
> >
> > fatal: Could not write blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
> >
>
> I get this for my git repo:
>
> $ git fast-export --all >/dev/null
> fatal: Could not write blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
> $ git cat-file blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 |wc -c
> 0
>
> Writing a zero-size blob will surely returns 0.
Indeed.
/me looking at too many piece of code at the same time
Nicolas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: 'git fast-export' is crashing on the gcc repo
2007-12-11 22:06 ` 'git fast-export' is crashing on the gcc repo Nicolas Pitre
@ 2007-12-12 1:38 ` Alex Riesen
2007-12-12 1:45 ` Nicolas Pitre
0 siblings, 1 reply; 10+ messages in thread
From: Alex Riesen @ 2007-12-12 1:38 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: git
Nicolas Pitre, Tue, Dec 11, 2007 23:06:42 +0100:
>
> Well, ignore the above. It seems that most of stdio doesn't set errno
> so the above is crap.
>
Well, it had no reason to in this case. It's not an error.
It does not even have to do a syscall.
> diff --git a/builtin-fast-export.c b/builtin-fast-export.c
> index 2136aad..c32a124 100755
> --- a/builtin-fast-export.c
> +++ b/builtin-fast-export.c
> @@ -103,7 +103,7 @@ static void handle_object(const unsigned char *sha1)
> mark_object(object);
>
> printf("blob\nmark :%d\ndata %lu\n", last_idnum, size);
> - if (fwrite(buf, size, 1, stdout) != 1)
> + if (fwrite(buf, 1, size, stdout) != size)
That's a probable syscall which could be spared
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: 'git fast-export' is crashing on the gcc repo
2007-12-12 1:38 ` Alex Riesen
@ 2007-12-12 1:45 ` Nicolas Pitre
2007-12-12 8:32 ` Junio C Hamano
0 siblings, 1 reply; 10+ messages in thread
From: Nicolas Pitre @ 2007-12-12 1:45 UTC (permalink / raw)
To: Alex Riesen; +Cc: git
On Wed, 12 Dec 2007, Alex Riesen wrote:
> Nicolas Pitre, Tue, Dec 11, 2007 23:06:42 +0100:
> >
> > Well, ignore the above. It seems that most of stdio doesn't set errno
> > so the above is crap.
> >
>
> Well, it had no reason to in this case. It's not an error.
> It does not even have to do a syscall.
Which is why I later agreed with your patch.
Nicolas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: 'git fast-export' is crashing on the gcc repo
2007-12-12 1:45 ` Nicolas Pitre
@ 2007-12-12 8:32 ` Junio C Hamano
2007-12-12 8:46 ` David Kastrup
0 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2007-12-12 8:32 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: Alex Riesen, git
Nicolas Pitre <nico@cam.org> writes:
> On Wed, 12 Dec 2007, Alex Riesen wrote:
>
>> Nicolas Pitre, Tue, Dec 11, 2007 23:06:42 +0100:
>> >
>> > Well, ignore the above. It seems that most of stdio doesn't set errno
>> > so the above is crap.
>> >
>>
>> Well, it had no reason to in this case. It's not an error.
>> It does not even have to do a syscall.
>
> Which is why I later agreed with your patch.
Still, I like your swapping of size and nmemb parameters, regardless of
the "don't bother calling fwrite(3) if size is zero" fix.
We are writing 1 element of size n-byte and expecting the call to return
1. It may be argued that writing one element of size 0-byte should
always write 1 element (without actually having to go down to write(2),
obviously) successfully and returning 0 from fwrite(3) is a bug ;-)
No, I am just kidding. I checked with POSIX and it clearly says it
should return 0 if size or nmemb is zero.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: 'git fast-export' is crashing on the gcc repo
2007-12-12 8:32 ` Junio C Hamano
@ 2007-12-12 8:46 ` David Kastrup
2007-12-12 8:56 ` Junio C Hamano
0 siblings, 1 reply; 10+ messages in thread
From: David Kastrup @ 2007-12-12 8:46 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Nicolas Pitre, Alex Riesen, git
Junio C Hamano <gitster@pobox.com> writes:
> Nicolas Pitre <nico@cam.org> writes:
>
>> On Wed, 12 Dec 2007, Alex Riesen wrote:
>>
>>> Nicolas Pitre, Tue, Dec 11, 2007 23:06:42 +0100:
>>> >
>>> > Well, ignore the above. It seems that most of stdio doesn't set errno
>>> > so the above is crap.
>>> >
>>>
>>> Well, it had no reason to in this case. It's not an error.
>>> It does not even have to do a syscall.
>>
>> Which is why I later agreed with your patch.
>
> Still, I like your swapping of size and nmemb parameters, regardless
> of the "don't bother calling fwrite(3) if size is zero" fix.
I don't. Far too obscure, looks like an unintentional wart waiting to
be corrected.
I think that the explicit test is the way to go here.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: 'git fast-export' is crashing on the gcc repo
2007-12-12 8:46 ` David Kastrup
@ 2007-12-12 8:56 ` Junio C Hamano
0 siblings, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2007-12-12 8:56 UTC (permalink / raw)
To: David Kastrup; +Cc: Nicolas Pitre, Alex Riesen, git
David Kastrup <dak@gnu.org> writes:
> Junio C Hamano <gitster@pobox.com> writes:
> ...
>> Still, I like your swapping of size and nmemb parameters, regardless
>> of the "don't bother calling fwrite(3) if size is zero" fix.
>
> I don't. Far too obscure, looks like an unintentional wart waiting to
> be corrected.
Oh, I did not mean it in the sense that would be a bugfix, but in the
sense that we are writing N instances of 1 byte, not 1 instance of N
byte blob, and should express size and nmemb parameters to fwrite(3) as
such. IOW, I would have preferred:
if (size && fwrite(buf, 1, size, stdout) != size)
barf(...);
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-12-12 8:57 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-11 20:27 'git fast-export' is crashing on the gcc repo Nicolas Pitre
2007-12-11 20:35 ` Marco Costalba
2007-12-11 22:01 ` [PATCH] Fix git-fast-export for zero-sized blobs Alex Riesen
2007-12-11 22:20 ` Nicolas Pitre
2007-12-11 22:06 ` 'git fast-export' is crashing on the gcc repo Nicolas Pitre
2007-12-12 1:38 ` Alex Riesen
2007-12-12 1:45 ` Nicolas Pitre
2007-12-12 8:32 ` Junio C Hamano
2007-12-12 8:46 ` David Kastrup
2007-12-12 8:56 ` Junio C Hamano
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).