git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Unaligned accesses in sha1dc

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jun 1, 2017, 10:33 UTC
Message-ID
<CACBZZX6H9EZTLVnunoH2641fw6QmQL=hO9isinK07-dHnuxyFQ@mail.gmail.com>
In-Reply-To
<CAN0heSrzpwhS3Zf83vTzHAAmi8YVD4CoCh_px5SBXBZhSKPqPQ@mail.gmail.com>
On Thu, Jun 1, 2017 at 12:26 PM, Martin Ågren <martin.agren@gmail.com> wrote:
Show 22 quoted lines
> On 1 June 2017 at 12:08, Andreas Schwab <schwab@suse.de> wrote:
>> On Jun 01 2017, Junio C Hamano <gitster@pobox.com> 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.

Previous: Martin ÅgrenNext: Martin Ågren
Message 11 of 28 in “Unaligned accesses in sha1dc”
  1. Andreas SchwabJun 1, 2017
  2. Junio C HamanoJun 1, 2017
  3. Andreas SchwabJun 1, 2017
  4. Junio C HamanoJun 1, 2017
  5. brian m. carlsonJun 1, 2017
  6. Andreas SchwabJun 1, 2017
  7. Lars SchneiderJun 1, 2017
  8. Junio C HamanoJun 1, 2017
  9. Andreas SchwabJun 1, 2017
  10. Martin ÅgrenJun 1, 2017
  11. Ævar Arnfjörð BjarmasonJun 1, 2017
  12. Martin ÅgrenJun 1, 2017
  13. Martin ÅgrenJun 1, 2017
  14. Junio C HamanoJun 2, 2017
  15. Ævar Arnfjörð BjarmasonJun 2, 2017
  16. Martin ÅgrenJun 2, 2017
  17. Ævar Arnfjörð BjarmasonJun 2, 2017
  18. Martin ÅgrenJun 2, 2017
  19. Ævar Arnfjörð BjarmasonJun 2, 2017
  20. demerphqJun 2, 2017
  21. demerphqJun 2, 2017
  22. Ævar Arnfjörð BjarmasonJun 2, 2017
  23. Linus TorvaldsJun 2, 2017
  24. Junio C HamanoJun 3, 2017
  25. Liam R. HowlettJun 2, 2017
  26. Ævar Arnfjörð BjarmasonJun 2, 2017
  27. Junio C HamanoJun 3, 2017
  28. Andreas SchwabJun 1, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.