Re: [PATCH 03/15] do not create "struct commit" with xcalloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 10, 2014 at 02:35:48PM -0700, Junio C Hamano wrote:

> Jeff King <peff@xxxxxxxx> writes:
> 
> > In both blame and merge-recursive, we sometimes create a
> > "fake" commit struct for convenience (e.g., to represent the
> > HEAD state as if we would commit it). By allocating
> > ourselves rather than using alloc_commit_node, we do not
> > properly set the "index" field of the commit. This can
> > produce subtle bugs if we then use commit-slab on the
> > resulting commit, as we will share the "0" index with
> > another commit.
> 
> The change I see here is all good, but I wonder if it is too late to
> start the real index from 1 and catch anything that has 0 index with
> a BUG("do not hand-allocate a commit").

Yeah, I had a similar thought while writing the series. I do not think
it is too late at all. It would just waste one commit's worth of memory
in the slab, but that is not a big deal. Other than slab_at, no callers
should care.

It would cost an extra conditional in each call to slab_at. That
probably doesn't matter, though the original goal was to make slab_at as
fast as an indirect pointer dereference (it's not quite these days,
though, as we have to do a little division to find the right section of
the slab).

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]