From: Jeff King <peff@peff.net>
To: Ali Utku Selen <auselen@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] shallow.c: Don't free unallocated slabs
Date: Tue, 1 Oct 2019 11:07:29 -0400 [thread overview]
Message-ID: <20191001150729.GI10875@sigill.intra.peff.net> (raw)
In-Reply-To: <20190930233310.19287-1-auselen@gmail.com>
On Tue, Oct 01, 2019 at 01:33:10AM +0200, Ali Utku Selen wrote:
> Fix possible segfault when cloning a submodule shallow.
Thanks. Just looking at the context, this is clearly the right thing to
be doing.
> It is possible to have unallocated slabs in shallow.c's commit_depth
> for a shallow submodule with many commits.
Yeah, the trick here is that we may over-allocate the slab list but not
fill all of the entries. This is really an internal implementation
detail of how the slab code works. It would be nice if callers didn't
have to care about it. Perhaps we ought to have a slab foreach()
function that encapsulates this, which would let this caller do
something like:
commit_depth_foreach(&depths, free_commit_depth);
commit_depth_clear(&depths);
But since this is the only place that looks into the slab in this way,
I'm happy to take your much simpler fix in the meantime.
> Easiest way to reproduce this I found was changing COMMIT_SLAB_SIZE to
> 32 and run t7406-submodule-update.sh. Segfault happens in case 50:
> "submodule update clone shallow submodule outside of depth"
It would be nice to have a test, but I suspect it would be kind of
expensive, since it requires 512kb+ of entries (and would obviously be
depending on this arbitrary internal value). Given the simplicity of the
fix, I think we can live without it.
-Peff
next prev parent reply other threads:[~2019-10-01 15:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-30 23:33 [PATCH] shallow.c: Don't free unallocated slabs Ali Utku Selen
2019-10-01 15:07 ` Jeff King [this message]
2019-10-02 6:01 ` Junio C Hamano
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=20191001150729.GI10875@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=auselen@gmail.com \
--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 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).