From: Junio C Hamano <gitster@pobox.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, worley@alum.mit.edu
Subject: Re: [PATCH v2 2/4] fsck: do not die when not enough memory to examine a pack entry
Date: Thu, 26 Jun 2014 11:09:07 -0700 [thread overview]
Message-ID: <xmqqa98z5yrg.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1403610336-27761-2-git-send-email-pclouds@gmail.com> ("Nguyễn Thái Ngọc Duy"'s message of "Tue, 24 Jun 2014 18:45:34 +0700")
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> fsck is a tool that error() is more preferred than die(), but many
"more preferred" without justifying why it is "more preferred" is
not quite a justification, is it? Also, an object failing to load
in-core is not a missing object, so if your aim is to let "fsck"
diagnose a too-large-to-load object as missing and let it continue,
I do not know if it is "more preferred" in the first place. Adding
a "too large--cannot check" bin of objects may be needed for it to
be useful. Also, we might need to give at the end "oh by the way,
because we couldn't read some objects to even determine its type,
the unreachable report from this fsck run is totally useless."
The log message tries to justify that this may be a good thing for
"fsck", but the patch actually tries to change the behaviour of all
code paths that try to load an object in-core without considering
the ramifications of such a change. I _think_ all callers should be
prepared to receive NULL when we encounter a corrupt object (and
otherwise we should fix them), but it is unclear how much audit of
the callers (if any) was done to prepare this change.
Not very excited X-<.
> functions embed die() inside beyond fsck's control.
> unpack_compressed_entry()'s using xmallocz is such a function,
> triggered from verify_packfile() -> unpack_entry(). Make it use
> xmallocz_gentle() instead.
>
> Noticed-by: Dale R. Worley <worley@alum.mit.edu>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> sha1_file.c | 4 +++-
> t/t1050-large.sh | 6 ++++++
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/sha1_file.c b/sha1_file.c
> index 34d527f..eb69c78 100644
> --- a/sha1_file.c
> +++ b/sha1_file.c
> @@ -1925,7 +1925,9 @@ static void *unpack_compressed_entry(struct packed_git *p,
> git_zstream stream;
> unsigned char *buffer, *in;
>
> - buffer = xmallocz(size);
> + buffer = xmallocz_gentle(size);
> + if (!buffer)
> + return NULL;
> memset(&stream, 0, sizeof(stream));
> stream.next_out = buffer;
> stream.avail_out = size + 1;
> diff --git a/t/t1050-large.sh b/t/t1050-large.sh
> index aea4936..5642f84 100755
> --- a/t/t1050-large.sh
> +++ b/t/t1050-large.sh
> @@ -163,4 +163,10 @@ test_expect_success 'zip achiving, deflate' '
> git archive --format=zip HEAD >/dev/null
> '
>
> +test_expect_success 'fsck' '
> + test_must_fail git fsck 2>err &&
> + n=$(grep "error: attempting to allocate .* over limit" err | wc -l) &&
> + test "$n" -gt 1
> +'
> +
> test_done
next prev parent reply other threads:[~2014-06-26 18:09 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-27 16:47 Git chokes on large file Dale R. Worley
2014-05-28 13:32 ` Duy Nguyen
2014-05-28 17:10 ` Junio C Hamano
2014-05-28 18:18 ` Dale R. Worley
2014-05-28 18:15 ` Dale R. Worley
2014-05-28 18:23 ` David Lang
2014-05-28 18:47 ` Dale R. Worley
2014-05-28 19:05 ` David Lang
2014-05-29 19:12 ` Dale R. Worley
2014-05-28 18:54 ` Junio C Hamano
2014-05-28 19:09 ` David Lang
2014-05-29 12:57 ` [PATCH 1/4] wrapper.c: introduce gentle xmallocz that does not die() Nguyễn Thái Ngọc Duy
2014-05-29 12:57 ` [PATCH 2/4] fsck: do not die when not enough memory to examine a pack entry Nguyễn Thái Ngọc Duy
2014-05-29 12:57 ` [PATCH 3/4] diff.c: allow to pass more flags to diff_populate_filespec Nguyễn Thái Ngọc Duy
2014-05-29 12:57 ` [PATCH 4/4] diff: mark any file larger than core.bigfilethreshold binary Nguyễn Thái Ngọc Duy
2014-06-19 12:27 ` Thomas Braun
2014-06-23 12:18 ` Duy Nguyen
2014-06-23 19:21 ` Thomas Braun
2014-06-24 11:45 ` [PATCH v2 1/4] wrapper.c: introduce gentle xmallocz that does not die() Nguyễn Thái Ngọc Duy
2014-06-24 11:45 ` [PATCH v2 2/4] fsck: do not die when not enough memory to examine a pack entry Nguyễn Thái Ngọc Duy
2014-06-26 18:09 ` Junio C Hamano [this message]
2014-06-29 0:40 ` Duy Nguyen
2014-06-24 11:45 ` [PATCH v2 3/4] diff.c: allow to pass more flags to diff_populate_filespec Nguyễn Thái Ngọc Duy
2014-06-24 11:45 ` [PATCH v2 4/4] diff: mark any file larger than core.bigfilethreshold binary Nguyễn Thái Ngọc Duy
2014-06-26 17:55 ` Junio C Hamano
2014-06-27 18:56 ` Thomas Braun
2014-06-29 1:11 ` Duy Nguyen
2014-08-13 10:57 ` [PATCH v3 0/6] Large file improvements Nguyễn Thái Ngọc Duy
2014-08-13 10:57 ` [PATCH v3 1/6] wrapper.c: introduce gentle xmalloc(z) that does not die() Nguyễn Thái Ngọc Duy
2014-08-14 16:38 ` Junio C Hamano
2014-08-13 10:57 ` [PATCH v3 2/6] sha1_file.c: do not die failing to malloc in unpack_compressed_entry Nguyễn Thái Ngọc Duy
2014-08-13 21:13 ` Junio C Hamano
2014-08-13 10:57 ` [PATCH v3 3/6] unpack-objects: continue when fail to malloc due to large objects Nguyễn Thái Ngọc Duy
2014-08-14 16:58 ` Junio C Hamano
2014-08-15 5:24 ` Duy Nguyen
2014-08-13 10:57 ` [PATCH v3 4/6] diff.c: allow to pass more flags to diff_populate_filespec Nguyễn Thái Ngọc Duy
2014-08-13 10:57 ` [PATCH v3 5/6] diff --stat: mark any file larger than core.bigfilethreshold binary Nguyễn Thái Ngọc Duy
2014-08-13 19:32 ` Eric Sunshine
2014-08-13 10:57 ` [PATCH v3 6/6] diff: shortcut for diff'ing two binary SHA-1 objects Nguyễn Thái Ngọc Duy
2014-08-14 17:00 ` Junio C Hamano
2014-08-15 12:11 ` Duy Nguyen
2014-08-14 17:17 ` Junio C Hamano
2014-08-16 3:08 ` [PATCH v4 0/5] Large file improvements Nguyễn Thái Ngọc Duy
2014-08-16 3:08 ` [PATCH v4 1/5] wrapper.c: introduce gentle xmallocz that does not die() Nguyễn Thái Ngọc Duy
2014-08-16 3:08 ` [PATCH v4 2/5] sha1_file.c: do not die failing to malloc in unpack_compressed_entry Nguyễn Thái Ngọc Duy
2014-08-16 3:08 ` [PATCH v4 3/5] diff.c: allow to pass more flags to diff_populate_filespec Nguyễn Thái Ngọc Duy
2014-08-16 3:08 ` [PATCH v4 4/5] diff --stat: mark any file larger than core.bigfilethreshold binary Nguyễn Thái Ngọc Duy
2014-08-16 3:08 ` [PATCH v4 5/5] diff: shortcut for diff'ing two binary SHA-1 objects Nguyễn Thái Ngọc Duy
2014-05-28 15:05 ` Git chokes on large file Thomas Braun
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=xmqqa98z5yrg.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
--cc=worley@alum.mit.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.