This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Rewritten v9/64-bit sparc strcmp.
- From: Aurelien Jarno <aurelien at aurel32 dot net>
- To: David Miller <davem at davemloft dot net>
- Cc: libc-alpha at sourceware dot org
- Date: Wed, 30 Apr 2014 18:09:33 +0200
- Subject: Re: [PATCH] Rewritten v9/64-bit sparc strcmp.
- Authentication-results: sourceware.org; auth=none
- References: <20110824 dot 013854 dot 674433294054458127 dot davem at davemloft dot net> <20140429095339 dot GA31556 at hall dot aurel32 dot net> <20140429 dot 224046 dot 1363822337091646659 dot davem at davemloft dot net>
On Tue, Apr 29, 2014 at 10:40:46PM -0400, David Miller wrote:
> From: Aurelien Jarno <aurelien@aurel32.net>
> Date: Tue, 29 Apr 2014 11:53:39 +0200
>
> > This method doesn't work when comparing a 0x00 char in string 1 and 0x01
> > char in string 2. In that case the mask for this byte is 0x01 and the
> > corresponding xor is also 0x01. The result of the comparison therefore
> > depends on the garbage after the end of the string.
> >
> > On Debian [1] this causes for example debian-installer to fail to build
> > [2], and it might be the source of the random segfaults which we are
> > trying to debug for a few years.
> >
> > [1] http://bugs.debian.org/746310
> > [2] http://bugs.debian.org/731806
>
> Right you are, if there are any zeros after the first zero we will
> potentially miscompare.
>
> The only solution I can see at the moment is to clear all except the
> topmost bit in the mask.
>
> Can you please test this patch?
Thanks a lot for this quick patch. I confirm it works correctly.
That said as the patch needs to test the mask byte by byte, I do wonder
if overall it wont be easier to directly test byte by byte the string
word loaded in the register. My SPARC assembly knowledge is relatively
limited, so I am not sure it is actually the case.
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
aurelien@aurel32.net http://www.aurel32.net