jc/lookup-object-hash from pu crashes on ARM
From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:52:21
Junio C Hamano wrote:
* jc/lookup-object-hash (2011-08-11) 6 commits - object hash: replace linear probing with 4-way cuckoo hashing - object hash: we know the table size is a power of two - object hash: next_size() helper for readability - pack-objects --count-only - object.c: remove duplicated code for object hashing - object.c: code movement for readability
The code from the tip commit crashes on ARM for me (and presumably
would also misbehave on other platforms that care about alignment):
$ git branch -av
Bus error
The following might avoid that:
static inline unsigned int H(const unsigned char *sha1, int ix)
{
unsigned int hash;
memcpy(&hash, sha1 + ix * sizeof(unsigned int),
sizeof(unsigned int));
return hash % (obj_hash_size - 1);
}
Even better could be to start aligning the hashes we pass around,
using something like this:
union object_hash {
unsigned char sha1[20];
uint32_t chunk[5];
};
which could speed up functions like hashcpy(), hashcmp(), and
hasheq(). But it's probably not worth the fuss.
Call chain:
cmd_branch -> print_ref_list -> for_each_rawref ->
do_for_each_ref -> do_one_ref(entry=0x175508) ->
append_ref(sha1=0x175509) ->
lookup_commit_reference_gently -> parse_object ->
parse_object_buffer -> lookup_commit -> lookup_object
This is from testing pu (ed7c265e), in case that's relevant. Aside
from that, the topic looks neat. :)