This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: my strstr is broken
- From: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- To: "adhemerval dot zanella at linaro dot org" <adhemerval dot zanella at linaro dot org>
- Cc: nd <nd at arm dot com>, "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>
- Date: Wed, 12 Sep 2018 13:11:29 +0000
- Subject: Re: my strstr is broken
Adhemerval wrote:
> On 11/09/2018 15:46, Wilco Dijkstra wrote:
>> Siddhesh wrote:
>>
>>> Is this a non-x86 architecture? I can reproduce this on the glibc
>>> 2.28 tag when I hack the ifunc resolver to ignore
>>> __strstr_sse2_unaligned and always use the stock __strstr.
>>
>> It's the generic strstr indeed. The issue is due to the long needle code using
>> the same AVAILABLE macro as for short needles. Since the macro now
>> ensures the haystack contains up to 512 valid characters, it cannot handle
>> needles which are longer than this. The fix is easy, just add the needle length.
>> I'll post a patch.
>
> Does it affect memmem as well? It would be useful to check it the tests
> are inadequate and fix them if the case for memmem.
Strcasestr uses the same readahead mechanism, but memmem is fine since it
doesn't use null-terminated strings. The issue is due to trying to avoid calling strlen
on the whole string - it's not obvious that's worth the increase in complexity.
Wilco