From: Jonathan Nieder <jrnieder@gmail.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v4 08/23] ewah: compressed bitmap implementation
Date: Wed, 22 Jan 2014 18:05:36 -0800 [thread overview]
Message-ID: <20140123020536.GP18964@google.com> (raw)
In-Reply-To: <20131221135953.GH21145@sigill.intra.peff.net>
Hi,
Jeff King wrote:
> EWAH is a word-aligned compressed variant of a bitset (i.e. a data
> structure that acts as a 0-indexed boolean array for many entries).
I suspect that for some callers it's not word-aligned.
Without the following squashed in, commits 212f2ffb and later fail t5310
on some machines[1].
On ARMv5:
expecting success:
git rev-list --test-bitmap HEAD
*** Error in `/«PKGBUILDDIR»/git': realloc(): invalid pointer: 0x008728b0 ***
Aborted
not ok 3 - rev-list --test-bitmap verifies bitmaps
On sparc:
expecting success:
git rev-list --test-bitmap HEAD
Bus error
not ok 3 - rev-list --test-bitmap verifies bitmaps
Hopefully it's possible to get the alignment right in the caller
and tweak the signature to require that instead of using unaligned
reads like this. There's still something wrong after this patch ---
the new result is a NULL pointer dereference in t5310.7 "enumerate
--objects (full bitmap)".
(gdb) run
Starting program: /home/jrnieder/src/git/git rev-list --objects --use-bitmap-index HEAD
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/sparc-linux-gnu/libthread_db.so.1".
537ea4d3eb79c95f602873b1167c480006d2ac2d
[...]
ec635144f60048986bc560c5576355344005e6e7
Program received signal SIGSEGV, Segmentation fault.
0x001321c0 in sha1_to_hex (sha1=0x0) at hex.c:68
68 unsigned int val = *sha1++;
(gdb) bt
#0 0x001321c0 in sha1_to_hex (sha1=0x0) at hex.c:68
#1 0x000b839c in show_object_fast (sha1=0x0, type=OBJ_TREE, exclude=0, name_hash=0, found_pack=0x2b8480, found_offset=4338) at builtin/rev-list.c:270
#2 0x00158abc in show_objects_for_type (objects=0x2b2498, type_filter=0x2b0fb0, object_type=OBJ_TREE, show_reach=0xb834c <show_object_fast>) at pack-bitmap.c:640
#3 0x001592d0 in traverse_bitmap_commit_list (show_reachable=0xb834c <show_object_fast>) at pack-bitmap.c:818
#4 0x000b894c in cmd_rev_list (argc=2, argv=0xffffd688, prefix=0x0) at builtin/rev-list.c:369
#5 0x00014024 in run_builtin (p=0x256e38 <commands+1020>, argc=4, argv=0xffffd688) at git.c:314
#6 0x00014330 in handle_builtin (argc=4, argv=0xffffd688) at git.c:487
#7 0x000144a8 in run_argv (argcp=0xffffd5ec, argv=0xffffd5a0) at git.c:533
#8 0x000146fc in main (argc=4, av=0xffffd684) at git.c:616
(gdb) frame 2
#2 0x00158abc in show_objects_for_type (objects=0x2b2498, type_filter=0x2b0fb0, object_type=OBJ_TREE, show_reach=0xb834c <show_object_fast>) at pack-bitmap.c:640
640 show_reach(sha1, object_type, 0, hash, bitmap_git.pack, entry->offset);
(gdb) p entry->nr
$1 = 4294967295
Line numbers are in the context of 8e6341d9. Ideas?
[1] ARMv5 and sparc:
https://buildd.debian.org/status/logs.php?pkg=git&suite=experimental
diff --git a/ewah/ewah_io.c b/ewah/ewah_io.c
index aed0da6..696a8ec 100644
--- a/ewah/ewah_io.c
+++ b/ewah/ewah_io.c
@@ -110,25 +110,38 @@ int ewah_serialize(struct ewah_bitmap *self, int fd)
return ewah_serialize_to(self, write_helper, (void *)(intptr_t)fd);
}
+#define get_be32(p) ( \
+ (*((unsigned char *)(p) + 0) << 24) | \
+ (*((unsigned char *)(p) + 1) << 16) | \
+ (*((unsigned char *)(p) + 2) << 8) | \
+ (*((unsigned char *)(p) + 3) << 0) )
+
+#define get_be64(p) ( \
+ ((uint64_t) get_be32(p) << 32) | \
+ get_be32((unsigned char *)(p) + 4) )
+
int ewah_read_mmap(struct ewah_bitmap *self, void *map, size_t len)
{
- uint32_t *read32 = map;
- eword_t *read64;
+ unsigned char *p = map;
size_t i;
- self->bit_size = ntohl(*read32++);
- self->buffer_size = self->alloc_size = ntohl(*read32++);
+ self->bit_size = get_be32(p);
+ p += 4;
+ self->buffer_size = self->alloc_size = get_be32(p);
+ p += 4;
self->buffer = ewah_realloc(self->buffer,
self->alloc_size * sizeof(eword_t));
if (!self->buffer)
return -1;
- for (i = 0, read64 = (void *)read32; i < self->buffer_size; ++i)
- self->buffer[i] = ntohll(*read64++);
+ for (i = 0; i < self->buffer_size; ++i) {
+ self->buffer[i] = get_be64(p);
+ p += 8;
+ }
- read32 = (void *)read64;
- self->rlw = self->buffer + ntohl(*read32++);
+ self->rlw = self->buffer + get_be32(p);
+ p += 4;
return (3 * 4) + (self->buffer_size * 8);
}
next prev parent reply other threads:[~2014-01-23 2:05 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-21 13:56 [PATCH v4 0/22] pack bitmaps Jeff King
2013-12-21 13:59 ` [PATCH v4 01/23] sha1write: make buffer const-correct Jeff King
2013-12-22 9:06 ` Christian Couder
2013-12-21 13:59 ` [PATCH v4 02/23] revindex: Export new APIs Jeff King
2013-12-21 13:59 ` [PATCH v4 03/23] pack-objects: Refactor the packing list Jeff King
2013-12-21 13:59 ` [PATCH v4 04/23] pack-objects: factor out name_hash Jeff King
2013-12-21 13:59 ` [PATCH v4 05/23] revision: allow setting custom limiter function Jeff King
2013-12-21 13:59 ` [PATCH v4 06/23] sha1_file: export `git_open_noatime` Jeff King
2013-12-21 13:59 ` [PATCH v4 07/23] compat: add endianness helpers Jeff King
2013-12-21 13:59 ` [PATCH v4 08/23] ewah: compressed bitmap implementation Jeff King
2014-01-23 2:05 ` Jonathan Nieder [this message]
2014-01-23 18:33 ` Jeff King
2014-01-23 18:35 ` [PATCH 1/2] compat: move unaligned helpers to bswap.h Jeff King
2014-01-23 19:41 ` Jonathan Nieder
2014-01-23 19:44 ` Jeff King
2014-01-23 19:56 ` Jonathan Nieder
2014-01-23 20:04 ` Jeff King
2014-01-23 20:08 ` Jonathan Nieder
2014-01-23 20:09 ` Jeff King
2014-01-23 18:35 ` [PATCH 2/2] ewah: support platforms that require aligned reads Jeff King
2014-01-23 19:52 ` [PATCH v4 08/23] ewah: compressed bitmap implementation Jonathan Nieder
2014-01-23 20:03 ` Jeff King
2014-01-23 20:12 ` Jonathan Nieder
2014-01-23 20:13 ` Jeff King
2014-01-23 20:23 ` Jonathan Nieder
2014-01-23 20:29 ` Jeff King
2014-01-23 20:38 ` Jeff King
2014-01-23 20:14 ` Shawn Pearce
2014-01-23 20:26 ` Jeff King
2014-01-23 21:53 ` brian m. carlson
2014-01-23 22:07 ` Jeff King
2014-01-23 22:17 ` Jonathan Nieder
2014-01-23 22:26 ` Jeff King
2014-01-23 22:33 ` Jonathan Nieder
2014-01-23 20:18 ` Jonathan Nieder
2014-01-23 21:20 ` [PATCH v2 0/3] unaligned reads from .bitmap files Jeff King
2014-01-23 21:23 ` [PATCH 1/3] block-sha1: factor out get_be and put_be wrappers Jeff King
2014-01-23 23:19 ` Jonathan Nieder
2014-01-23 21:26 ` [PATCH 2/3] read-cache: use get_be32 instead of hand-rolled ntoh_l Jeff King
2014-01-23 23:34 ` Jonathan Nieder
2014-01-24 2:22 ` Jeff King
2014-01-23 21:27 ` [PATCH 3/3] ewah: support platforms that require aligned reads Jeff King
2014-01-23 23:44 ` Jonathan Nieder
2014-01-23 23:49 ` Vicent Martí
2014-01-24 0:15 ` Jonathan Nieder
2014-01-23 23:17 ` [PATCH v2 0/3] unaligned reads from .bitmap files Jonathan Nieder
2013-12-21 13:59 ` [PATCH v4 09/23] documentation: add documentation for the bitmap format Jeff King
2013-12-21 14:00 ` [PATCH v4 10/23] pack-bitmap: add support for bitmap indexes Jeff King
2013-12-21 14:00 ` [PATCH v4 11/23] pack-objects: split add_object_entry Jeff King
2013-12-21 14:00 ` [PATCH v4 12/23] pack-objects: use bitmaps when packing objects Jeff King
2013-12-21 14:00 ` [PATCH v4 13/23] rev-list: add bitmap mode to speed up object lists Jeff King
2013-12-21 14:00 ` [PATCH v4 14/23] pack-objects: implement bitmap writing Jeff King
2013-12-21 14:00 ` [PATCH v4 15/23] repack: stop using magic number for ARRAY_SIZE(exts) Jeff King
2013-12-21 14:00 ` [PATCH v4 16/23] repack: turn exts array into array-of-struct Jeff King
2013-12-21 14:00 ` [PATCH v4 17/23] repack: handle optional files created by pack-objects Jeff King
2013-12-21 14:00 ` [PATCH v4 18/23] repack: consider bitmaps when performing repacks Jeff King
2013-12-21 14:00 ` [PATCH v4 19/23] count-objects: recognize .bitmap in garbage-checking Jeff King
2013-12-21 14:00 ` [PATCH v4 20/23] t: add basic bitmap functionality tests Jeff King
2013-12-21 14:00 ` [PATCH v4 21/23] t/perf: add tests for pack bitmaps Jeff King
2013-12-21 14:00 ` [PATCH v4 22/23] pack-bitmap: implement optional name_hash cache Jeff King
2013-12-21 14:00 ` [PATCH v4 23/23] compat/mingw.h: Fix the MinGW and msvc builds Jeff King
2013-12-25 22:08 ` Erik Faye-Lund
2013-12-28 10:00 ` Jeff King
2013-12-28 10:06 ` Vicent Martí
2013-12-28 15:58 ` Ramsay Jones
2013-12-21 14:03 ` [PATCH v4 0/22] pack bitmaps Jeff King
2013-12-21 14:05 ` Jeff King
2013-12-21 18:34 ` Thomas Rast
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=20140123020536.GP18964@google.com \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/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).