{"thread":{"id":"46262","subject":"[PATCH] pack-bitmap: Don't perform unaligned memory access","startedAt":"2017-06-26T15:16:35Z","lastAt":"2017-06-27T00:06:15Z","messageCount":3,"participants":["James Clarke","Junio C Hamano","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"323271","messageId":"20170626151612.64019-1-jrtc27@jrtc27.com","threadId":"46262","inReplyTo":null,"subject":"[PATCH] pack-bitmap: Don't perform unaligned memory access","fromName":"James Clarke","fromEmail":"jrtc27@jrtc27.com","sentAt":"2017-06-26T15:16:12Z","receivedAt":"2017-06-26T15:16:35Z","isPatch":true,"sender":{"key":"jrtc27@jrtc27.com","avatar":"https://avatars.githubusercontent.com/u/816232?v=4"},"body":"The preceding bitmap entries have a 1-byte XOR-offset and 1-byte flags,\nso their size is not a multiple of 4. Thus the name-hash cache is only\nguaranteed to be 2-byte aligned and so we must use get_be32 rather than\nindexing the array directly.\n\nSigned-off-by: James Clarke <jrtc27@jrtc27.com>\n---\n\nThis was noticed thanks to the recent tests added to t5310-pack-bitmaps.sh,\nwhich were crashing with SIGBUS on Debian sparc64. All tests (excluding those\nmarked with known breakage) now pass again.\n\n pack-bitmap.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/pack-bitmap.c b/pack-bitmap.c\nindex a3ac3dccd..327634cd7 100644\n--- a/pack-bitmap.c\n+++ b/pack-bitmap.c\n@@ -627,7 +627,7 @@ static void show_objects_for_type(\n \t\t\tsha1 = nth_packed_object_sha1(bitmap_git.pack, entry->nr);\n\n \t\t\tif (bitmap_git.hashes)\n-\t\t\t\thash = ntohl(bitmap_git.hashes[entry->nr]);\n+\t\t\t\thash = get_be32(bitmap_git.hashes + entry->nr);\n\n \t\t\tshow_reach(sha1, object_type, 0, hash, bitmap_git.pack, entry->offset);\n \t\t}\n--\n2.13.2\n\n"},{"id":"323291","messageId":"xmqqr2y64kdj.fsf@gitster.mtv.corp.google.com","threadId":"46262","inReplyTo":"20170626151612.64019-1-jrtc27@jrtc27.com","subject":"Re: [PATCH] pack-bitmap: Don't perform unaligned memory access","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-26T19:30:32Z","receivedAt":"2017-06-26T19:32:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"James Clarke <jrtc27@jrtc27.com> writes:\n\n> The preceding bitmap entries have a 1-byte XOR-offset and 1-byte flags,\n> so their size is not a multiple of 4. Thus the name-hash cache is only\n> guaranteed to be 2-byte aligned and so we must use get_be32 rather than\n> indexing the array directly.\n>\n> Signed-off-by: James Clarke <jrtc27@jrtc27.com>\n> ---\n>\n> This was noticed thanks to the recent tests added to t5310-pack-bitmaps.sh,\n> which were crashing with SIGBUS on Debian sparc64. All tests (excluding those\n> marked with known breakage) now pass again.\n\nThanks.\n\n>\n>  pack-bitmap.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/pack-bitmap.c b/pack-bitmap.c\n> index a3ac3dccd..327634cd7 100644\n> --- a/pack-bitmap.c\n> +++ b/pack-bitmap.c\n> @@ -627,7 +627,7 @@ static void show_objects_for_type(\n>  \t\t\tsha1 = nth_packed_object_sha1(bitmap_git.pack, entry->nr);\n>\n>  \t\t\tif (bitmap_git.hashes)\n> -\t\t\t\thash = ntohl(bitmap_git.hashes[entry->nr]);\n> +\t\t\t\thash = get_be32(bitmap_git.hashes + entry->nr);\n>\n>  \t\t\tshow_reach(sha1, object_type, 0, hash, bitmap_git.pack, entry->offset);\n>  \t\t}\n> --\n> 2.13.2\n"},{"id":"323305","messageId":"20170627000600.GD161648@aiede.mtv.corp.google.com","threadId":"46262","inReplyTo":"20170626151612.64019-1-jrtc27@jrtc27.com","subject":"Re: [PATCH] pack-bitmap: Don't perform unaligned memory access","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2017-06-27T00:06:00Z","receivedAt":"2017-06-27T00:06:15Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"James Clarke wrote:\n\n> The preceding bitmap entries have a 1-byte XOR-offset and 1-byte flags,\n> so their size is not a multiple of 4. Thus the name-hash cache is only\n> guaranteed to be 2-byte aligned and so we must use get_be32 rather than\n> indexing the array directly.\n>\n> Signed-off-by: James Clarke <jrtc27@jrtc27.com>\n> ---\n>  pack-bitmap.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n\nReviewed-by: Jonathan Nieder <jrnieder@gmail.com>\n\nFailing build log:\nhttps://buildd.debian.org/status/fetch.php?pkg=git&arch=sparc64&ver=1%3A2.13.2-2&stamp=1498520310&raw=0\n\nThanks for tracking down and fixing it.\n"}]}