From: Junio C Hamano <gitster@pobox.com>
To: Eric Wong <e@80x24.org>
Cc: git@vger.kernel.org
Subject: Re: [HOLD 3/4] check_packed_git_idx: attempt to handle ENOMEM from mmap
Date: Tue, 29 Jun 2021 14:33:49 -0700 [thread overview]
Message-ID: <xmqqbl7owe2q.fsf@gitster.g> (raw)
In-Reply-To: 20210629202101.GA18279@dcvr
Eric Wong <e@80x24.org> writes:
> Eric Wong <e@80x24.org> wrote:
>> --- a/packfile.c
>> +++ b/packfile.c
>> @@ -97,7 +97,11 @@ static int check_packed_git_idx(const char *path, struct packed_git *p)
>> close(fd);
>> return error("index file %s is too small", path);
>> }
>> - idx_map = xmmap(NULL, idx_size, PROT_READ, MAP_PRIVATE, fd, 0);
>> + do {
>> + idx_map = xmmap_gently(NULL, idx_size, PROT_READ, MAP_PRIVATE,
>> + fd, 0);
>> + } while (idx_map == MAP_FAILED && errno == ENOMEM
>> + && unuse_one_window(p));
>
> Oops, I dropped extra error handling here :x
>
>> close(fd);
>>
>> ret = load_idx(path, hashsz, idx_map, idx_size, p);
Something like this, perhaps? You'd also need _() around the error
message you added to object-file.c in [2/4], I would think.
packfile.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git c/packfile.c w/packfile.c
index 2904560f52..b31f14ecb7 100644
--- c/packfile.c
+++ w/packfile.c
@@ -102,6 +102,10 @@ static int check_packed_git_idx(const char *path, struct packed_git *p)
fd, 0);
} while (idx_map == MAP_FAILED && errno == ENOMEM
&& unuse_one_window(p));
+ if (idx_map == MAP_FAILED) {
+ close(fd);
+ return error_errno(_("%s cannot be mapped"), path);
+ }
close(fd);
ret = load_idx(path, hashsz, idx_map, idx_size, p);
next prev parent reply other threads:[~2021-06-29 21:33 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-29 8:11 [PATCH 0/4] gracefully handling mmap failures Eric Wong
2021-06-29 8:11 ` [PATCH 1/4] use_pack: attempt to handle ENOMEM from mmap Eric Wong
2021-06-30 2:30 ` Jeff King
2021-06-29 8:11 ` [PATCH 2/4] map_loose_object_1: " Eric Wong
2021-06-30 2:41 ` Jeff King
2021-06-30 6:06 ` Ævar Arnfjörð Bjarmason
2021-06-29 8:11 ` [PATCH 3/4] check_packed_git_idx: " Eric Wong
2021-06-29 20:21 ` [HOLD " Eric Wong
2021-06-29 21:33 ` Junio C Hamano [this message]
2021-06-29 22:31 ` Eric Wong
2021-06-29 8:11 ` [PATCH 4/4] xmmap: inform Linux users of tuning knobs on ENOMEM Eric Wong
2021-06-30 0:01 ` [PATCH v2] " Eric Wong
2021-06-30 2:46 ` Jeff King
2021-06-30 10:07 ` Eric Wong
2021-06-30 17:18 ` Jeff King
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=xmqqbl7owe2q.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=e@80x24.org \
--cc=git@vger.kernel.org \
/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.