Unaligned accesses in sha1dc

2017-06-01 Thread Andreas Schwab
The sh1dc implementation is making unaligned accesses, which will crash on some architectures, others have to emulate them in software. Breakpoint 4, sha1_compression_states (ihv=0x600e7010, m=, W=0x600e70a8, states=0x600e7328) at sha1dc/sha1.c:398 398

Re: Unaligned accesses in sha1dc

2017-06-01 Thread Andreas Schwab
SHA1DCUpdate calls sha1_process with buf being unaligned. Andreas. -- Andreas Schwab, SUSE Labs, sch...@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."

Re: Unaligned accesses in sha1dc

2017-06-01 Thread Junio C Hamano
Is this with or without a0103914 ("sha1dc: update from upstream", 2017-05-20)?

Re: Unaligned accesses in sha1dc

2017-06-01 Thread Andreas Schwab
This is git 2.13.0. Andreas. -- Andreas Schwab, SUSE Labs, sch...@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."

Re: Unaligned accesses in sha1dc

2017-06-01 Thread brian m. carlson
On Thu, Jun 01, 2017 at 10:28:52AM +0200, Andreas Schwab wrote: > The sh1dc implementation is making unaligned accesses, which will crash > on some architectures, others have to emulate them in software. > > Breakpoint 4, sha1_compression_states (ihv=0x600e7010, > m=, W=0x600e

Re: Unaligned accesses in sha1dc

2017-06-01 Thread Lars Schneider
> On 01 Jun 2017, at 10:28, Andreas Schwab wrote: > > The sh1dc implementation is making unaligned accesses, which will crash > on some architectures, others have to emulate them in software. Is SPARC an architecture that would run into this problem? I think there was a thread a few days ago ab

Re: Unaligned accesses in sha1dc

2017-06-01 Thread Andreas Schwab
On Jun 01 2017, "brian m. carlson" wrote: > On Thu, Jun 01, 2017 at 10:28:52AM +0200, Andreas Schwab wrote: >> The sh1dc implementation is making unaligned accesses, which will crash >> on some architectures, others have to emulate them in software. >> >> Breakpoint 4, sha1_compression_states (i

Re: Unaligned accesses in sha1dc

2017-06-01 Thread Junio C Hamano
Andreas Schwab writes: > This is git 2.13.0. Thanks. It is a known issue with a known fix cooking in 'next' to be merged down to 'master' and 'maint' not in a too distant future. An extra testing to ensure that the "fix" actually works before it is merged down to a maintenance release is very m

Re: Unaligned accesses in sha1dc

2017-06-01 Thread Junio C Hamano
Lars Schneider writes: >> On 01 Jun 2017, at 10:28, Andreas Schwab wrote: >> >> The sh1dc implementation is making unaligned accesses, which will crash >> on some architectures, others have to emulate them in software. > > Is SPARC an architecture that would run into this problem? I think > the

Re: Unaligned accesses in sha1dc

2017-06-01 Thread Andreas Schwab
On Jun 01 2017, Junio C Hamano 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.

Re: Unaligned accesses in sha1dc

2017-06-01 Thread Martin Ågren
On 1 June 2017 at 12:08, Andreas Schwab wrote: > On Jun 01 2017, Junio C Hamano 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-ac

Re: Unaligned accesses in sha1dc

2017-06-01 Thread Ævar Arnfjörð Bjarmason
On Thu, Jun 1, 2017 at 12:26 PM, Martin Ågren wrote: > On 1 June 2017 at 12:08, Andreas Schwab wrote: >> On Jun 01 2017, Junio C Hamano 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

Re: Unaligned accesses in sha1dc

2017-06-01 Thread Martin Ågren
On 1 June 2017 at 12:33, Ævar Arnfjörð Bjarmason wrote: > On Thu, Jun 1, 2017 at 12:26 PM, Martin Ågren wrote: >> On 1 June 2017 at 12:08, Andreas Schwab wrote: >>> Even if the architecture implements unaligned accesses in hardware, it >>> is still undefined behaviour, and the compiler will (eve

Re: Unaligned accesses in sha1dc

2017-06-01 Thread Martin Ågren
On 1 June 2017 at 13:53, Martin Ågren wrote: > On 1 June 2017 at 12:33, Ævar Arnfjörð Bjarmason wrote: >> On Thu, Jun 1, 2017 at 12:26 PM, Martin Ågren wrote: >>> On 1 June 2017 at 12:08, Andreas Schwab wrote: Even if the architecture implements unaligned accesses in hardware, it is s

Re: Unaligned accesses in sha1dc

2017-06-01 Thread Junio C Hamano
Martin Ågren writes: > I looked into this some more. It turns out it is possible to trigger > undefined behavior on "next". Here's what I did: > ... > > This "fixes" the problem: > ... > diff --git a/sha1dc/sha1.c b/sha1dc/sha1.c > index 3dff80a..d6f4c44 100644 > --- a/sha1dc/sha1.c > +++ b/sha1d

Re: Unaligned accesses in sha1dc

2017-06-02 Thread Ævar Arnfjörð Bjarmason
On Fri, Jun 2, 2017 at 2:15 AM, Junio C Hamano wrote: > Martin Ågren writes: > >> I looked into this some more. It turns out it is possible to trigger >> undefined behavior on "next". Here's what I did: >> ... >> >> This "fixes" the problem: >> ... >> diff --git a/sha1dc/sha1.c b/sha1dc/sha1.c >>

Re: Unaligned accesses in sha1dc

2017-06-02 Thread Martin Ågren
On 2 June 2017 at 10:51, Ævar Arnfjörð Bjarmason wrote: > On Fri, Jun 2, 2017 at 2:15 AM, Junio C Hamano wrote: >> Martin Ågren writes: >> >>> I looked into this some more. It turns out it is possible to trigger >>> undefined behavior on "next". Here's what I did: >>> ... >>> >>> This "fixes" th

Re: Unaligned accesses in sha1dc

2017-06-02 Thread Liam R. Howlett
* ?var Arnfj?r? Bjarmason [170602 04:53]: > On Fri, Jun 2, 2017 at 2:15 AM, Junio C Hamano wrote: > > Martin Ågren writes: > > > >> I looked into this some more. It turns out it is possible to trigger > >> undefined behavior on "next". Here's what I did: > >> ... > >> > >> This "fixes" the probl

Re: Unaligned accesses in sha1dc

2017-06-02 Thread Ævar Arnfjörð Bjarmason
On Fri, Jun 2, 2017 at 4:46 PM, Liam R. Howlett wrote: > * ?var Arnfj?r? Bjarmason [170602 04:53]: >> On Fri, Jun 2, 2017 at 2:15 AM, Junio C Hamano wrote: >> > Martin Ågren writes: >> > >> >> I looked into this some more. It turns out it is possible to trigger >> >> undefined behavior on "next

Re: Unaligned accesses in sha1dc

2017-06-02 Thread Ævar Arnfjörð Bjarmason
On Fri, Jun 2, 2017 at 11:49 AM, Martin Ågren wrote: > On 2 June 2017 at 10:51, Ævar Arnfjörð Bjarmason wrote: >> On Fri, Jun 2, 2017 at 2:15 AM, Junio C Hamano wrote: >>> Martin Ågren writes: >>> I looked into this some more. It turns out it is possible to trigger undefined behavior

Re: Unaligned accesses in sha1dc

2017-06-02 Thread Martin Ågren
On 2 June 2017 at 21:32, Ævar Arnfjörð Bjarmason wrote: > On Fri, Jun 2, 2017 at 11:49 AM, Martin Ågren wrote: >> On 2 June 2017 at 10:51, Ævar Arnfjörð Bjarmason wrote: >>> On Fri, Jun 2, 2017 at 2:15 AM, Junio C Hamano wrote: Martin Ågren writes: > I looked into this some more.

Re: Unaligned accesses in sha1dc

2017-06-02 Thread Ævar Arnfjörð Bjarmason
On Fri, Jun 2, 2017 at 10:11 PM, Martin Ågren wrote: > On 2 June 2017 at 21:32, Ævar Arnfjörð Bjarmason wrote: >> On Fri, Jun 2, 2017 at 11:49 AM, Martin Ågren wrote: >>> On 2 June 2017 at 10:51, Ævar Arnfjörð Bjarmason wrote: On Fri, Jun 2, 2017 at 2:15 AM, Junio C Hamano wrote: > Ma

Re: Unaligned accesses in sha1dc

2017-06-02 Thread demerphq
On 2 June 2017 at 21:32, Ævar Arnfjörð Bjarmason wrote: > On Fri, Jun 2, 2017 at 11:49 AM, Martin Ågren wrote: >> On 2 June 2017 at 10:51, Ævar Arnfjörð Bjarmason wrote: >>> On Fri, Jun 2, 2017 at 2:15 AM, Junio C Hamano wrote: Martin Ågren writes: > I looked into this some more.

Re: Unaligned accesses in sha1dc

2017-06-02 Thread demerphq
On 2 June 2017 at 22:14, Ævar Arnfjörð Bjarmason wrote: > On Fri, Jun 2, 2017 at 10:11 PM, Martin Ågren wrote: >> On 2 June 2017 at 21:32, Ævar Arnfjörð Bjarmason wrote: >>> On Fri, Jun 2, 2017 at 11:49 AM, Martin Ågren >>> wrote: On 2 June 2017 at 10:51, Ævar Arnfjörð Bjarmason wrote: >

Re: Unaligned accesses in sha1dc

2017-06-02 Thread Ævar Arnfjörð Bjarmason
On Fri, Jun 2, 2017 at 10:17 PM, demerphq wrote: > On 2 June 2017 at 21:32, Ævar Arnfjörð Bjarmason wrote: >> On Fri, Jun 2, 2017 at 11:49 AM, Martin Ågren wrote: >>> On 2 June 2017 at 10:51, Ævar Arnfjörð Bjarmason wrote: On Fri, Jun 2, 2017 at 2:15 AM, Junio C Hamano wrote: > Martin

Re: Unaligned accesses in sha1dc

2017-06-02 Thread Linus Torvalds
On Fri, Jun 2, 2017 at 1:17 PM, demerphq wrote: > Most hash function implementations have code like the following > (extracted and reduced from hv_macro.h in perl.git [which only > supports little-endian hash functions]): Yes. Please do *not* try to make things overly portable by adding random m

Re: Unaligned accesses in sha1dc

2017-06-02 Thread Junio C Hamano
Linus Torvalds writes: > Dereferencing an unaligned pointer may be "undefined" in some > technical meaning, but it sure as hell isn't undefined in reality, and > compilers that willfully do stupid things should not be catered to > overly. Reality is a lot more important. Thanks for succinctly pu

Re: Unaligned accesses in sha1dc

2017-06-02 Thread Junio C Hamano
Ævar Arnfjörð Bjarmason writes: > On Fri, Jun 2, 2017 at 4:46 PM, Liam R. Howlett > wrote: > >> 2.13.0 is very much broken for me on SPARC. >> {maint//git} $ make -j120 >> [...] >> {maint//git} $ ./git log >> [1]1004506 bus error (core dumped) ./git log >> >> This is with b06d36431 (maint)