Re: Unaligned accesses in sha1dc

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

 



On Thu, Jun 1, 2017 at 12:26 PM, Martin Ågren <martin.agren@xxxxxxxxx> wrote:
> On 1 June 2017 at 12:08, Andreas Schwab <schwab@xxxxxxx> wrote:
>> On Jun 01 2017, Junio C Hamano <gitster@xxxxxxxxx> wrote:
>>
>>> Depending on the model of "ARM" (or "SPARC") emulated with QEMU, and
>>> depending on the OS that runs on such an "ARM" or "SPARC", we may
>>> not see this---if the emulated OS has the "software unaligned-access
>>> emulation" our userland may not see a SIGBUS.
>>
>> Even if the architecture implements unaligned accesses in hardware, it
>> is still undefined behaviour, and the compiler will (eventually) take
>> advantage of it.
>
> I tried to optically follow the macros and ended up on line 87/89 in
> lib/sha1.c of the sha1dc-library, where there is undefined behavior if
> the address is unaligned, which it seems it could be. Maybe Git uses
> some particular combination of macro-definitions and I went down the
> wrong path... There might also be other spots; I haven't thrown UBSan
> at the code.
>
> Using memcpy on those lines should not be a performance problem on
> platforms where unaligned access is ok, of course assuming the
> compiler sees the opportunity.

This is what the upstream version of sha1dc now in the next branch
does, i.e. just does a memcpy() on platforms which aren't on a
whitelist of CPUs that allow unaligned access.




[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]