From: Jeff King <peff@peff.net>
To: "Kyle J. McKay" <mackyle@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH] pack-bitmap: do not core dump
Date: Tue, 22 Apr 2014 19:17:48 -0400 [thread overview]
Message-ID: <20140422231748.GA20353@sigill.intra.peff.net> (raw)
In-Reply-To: <781073ea08e86301f62e708bc0b80fd@74d39fa044aa309eaea14b9f57fe79c>
On Tue, Apr 22, 2014 at 03:53:02PM -0700, Kyle J. McKay wrote:
> So I was trying to use pack.writebitmaps=true and all I got was core dumps.
Eek.
> The fix with a real subject line ;) is below. I think perhaps this should be
> picked up for the 2.0.0 release. (Patch is against master.)
Yes, this is definitely the sort of bugfix we want to see during the -rc
period (well, we would prefer not to see bugs at all, but if we must
have them, fixes are helpful).
> ---- >8 ----
> Subject: [PATCH] ewah_bitmap.c: do not assume size_t and eword_t are the same size
Thanks for a very well-written commit message. I think your fix makes
sense:
> - self->rlw = self->buffer + (rlw_offset / sizeof(size_t));
> + self->rlw = self->buffer + (rlw_offset / sizeof(eword_t));
We could also write it as:
self->rlw = (uint8_t *)self->buffer + rlw_offset;
but I do not think that is necessarily any more readable, especially
because we probably need to cast it like:
self->rlw = (eword_t *)((uint8_t *)self->buffer + rlw_offset);
Given that self->rlw is a pointer to eword_t, though, we can assume
rlw_offset is always going to be a multiple of sizeof(eword_t) anyway
(and if it is not, the division in the original is a big problem, but I
do not think that is the case). So why do any uint8_t math in the first
place? I think we could write it as:
eword_t *old = self->buffer;
... realloc ...
self->rlw = self->buffer + (self->rlw - old);
I'm fine with your patch, though.
I also poked through the rest of the bitmap code looking for similar
problems, but didn't find any. I do not think this was a systemic issue
with bad use of types; it was just a think-o that happened to work on
64-bit machines.
-Peff
next prev parent reply other threads:[~2014-04-22 23:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-22 22:53 [PATCH] pack-bitmap: do not core dump Kyle J. McKay
2014-04-22 23:11 ` Junio C Hamano
2014-04-22 23:17 ` Jeff King [this message]
2014-04-23 0:40 ` Kyle J. McKay
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=20140422231748.GA20353@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mackyle@gmail.com \
/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).