public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* my strstr is broken
@ 2018-09-10 14:47 Michael Brunnbauer
  2018-09-11 10:27 ` Michael Brunnbauer
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Brunnbauer @ 2018-09-10 14:47 UTC (permalink / raw)
  To: libc-help


[-- Attachment #1.1: Type: text/plain, Size: 2306 bytes --]


hi

can someone reproduce this with 2.28 (program exits with return code 255)?

-----------------------------------------------------------
#include <string.h>

int main (void)
{
 char* i = "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
 char* n = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
 if (!strstr(i,n)) return 255;
 return 0;
}
-----------------------------------------------------------

cu,
brunni

-- 
++  Michael Brunnbauer
++  netEstate GmbH
++  Geisenhausener Straße 11a
++  81379 München
++  Tel +49 89 32 19 77 80
++  Fax +49 89 32 19 77 89 
++  E-Mail brunni@netestate.de
++  https://www.netestate.de/
++
++  Sitz: München, HRB Nr.142452 (Handelsregister B München)
++  USt-IdNr. DE221033342
++  Geschäftsführer: Michael Brunnbauer, Franz Brunnbauer
++  Prokurist: Dipl. Kfm. (Univ.) Markus Hendel

[-- Attachment #1.2: test.c --]
[-- Type: text/plain, Size: 1661 bytes --]

#include <string.h>

int main (void)
{
 char* i = "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
 char* n = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
 if (!strstr(i,n)) return 255;
 return 0;
}

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 163 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: my strstr is broken
  2018-09-10 14:47 my strstr is broken Michael Brunnbauer
@ 2018-09-11 10:27 ` Michael Brunnbauer
  2018-09-11 12:58   ` Allin Cottrell
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Brunnbauer @ 2018-09-11 10:27 UTC (permalink / raw)
  To: libc-help

[-- Attachment #1: Type: text/plain, Size: 4789 bytes --]


hi all,

I assume it cannot be reproduced and is limited to my build?

Any ideas/hints for me? The fact that the needle is 513 bytes and occurs at
an offset of 513 bytes in the haystack should provide some clue?

cu,
brunni

On Mon, Sep 10, 2018 at 04:47:52PM +0200, Michael Brunnbauer wrote:
> 
> hi
> 
> can someone reproduce this with 2.28 (program exits with return code 255)?
> 
> -----------------------------------------------------------
> #include <string.h>
> 
> int main (void)
> {
>  char* i = "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
>  char* n = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
>  if (!strstr(i,n)) return 255;
>  return 0;
> }
> -----------------------------------------------------------
> 
> cu,
> brunni
> 
> -- 
> ++  Michael Brunnbauer
> ++  netEstate GmbH
> ++  Geisenhausener Straße 11a
> ++  81379 München
> ++  Tel +49 89 32 19 77 80
> ++  Fax +49 89 32 19 77 89 
> ++  E-Mail brunni@netestate.de
> ++  https://www.netestate.de/
> ++
> ++  Sitz: München, HRB Nr.142452 (Handelsregister B München)
> ++  USt-IdNr. DE221033342
> ++  Geschäftsführer: Michael Brunnbauer, Franz Brunnbauer
> ++  Prokurist: Dipl. Kfm. (Univ.) Markus Hendel

> #include <string.h>
> 
> int main (void)
> {
>  char* i = "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
>  char* n = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
>  if (!strstr(i,n)) return 255;
>  return 0;
> }




-- 
++  Michael Brunnbauer
++  netEstate GmbH
++  Geisenhausener Straße 11a
++  81379 München
++  Tel +49 89 32 19 77 80
++  Fax +49 89 32 19 77 89 
++  E-Mail brunni@netestate.de
++  https://www.netestate.de/
++
++  Sitz: München, HRB Nr.142452 (Handelsregister B München)
++  USt-IdNr. DE221033342
++  Geschäftsführer: Michael Brunnbauer, Franz Brunnbauer
++  Prokurist: Dipl. Kfm. (Univ.) Markus Hendel

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 163 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: my strstr is broken
  2018-09-11 10:27 ` Michael Brunnbauer
@ 2018-09-11 12:58   ` Allin Cottrell
  2018-09-11 13:54     ` Michael Brunnbauer
  0 siblings, 1 reply; 10+ messages in thread
From: Allin Cottrell @ 2018-09-11 12:58 UTC (permalink / raw)
  To: Michael Brunnbauer; +Cc: libc-help

[-- Attachment #1: Type: text/plain, Size: 2911 bytes --]

On Tue, 11 Sep 2018, Michael Brunnbauer wrote:

> hi all,
>
> I assume it cannot be reproduced and is limited to my build?
>
> Any ideas/hints for me? The fact that the needle is 513 bytes and occurs at
> an offset of 513 bytes in the haystack should provide some clue?
>
> cu,
> brunni
>
> On Mon, Sep 10, 2018 at 04:47:52PM +0200, Michael Brunnbauer wrote:
>>
>> can someone reproduce this with 2.28 (program exits with return code 255)?
>>
>> -----------------------------------------------------------
>> #include <string.h>
>>
>> int main (void)
>> {
>>  char* i = "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
>>  char* n = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
>>  if (!strstr(i,n)) return 255;
>>  return 0;
>> }

Since it's difficult to verify your long strings in email I tried the 
following variant of your test:

#include <string.h>
#include <stdio.h>

int main (void)
{
     char h[513*2+1];
     char n[513+1];
     char *s;
     int i;

     for (i=0; i<513; i++) {
         n[i] = 'x';
         h[i] = ' ';
         h[i+513] = 'x';
     }
     n[513] = '\0';
     h[513*2] = '\0';

     printf("h=\"%s\"\n", h);
     printf("n=\"%s\"\n", n);
     s = strstr(h, n);
     printf("s = %p\n", (void *) s);
     printf("strcmp(n, s) = %d\n", strcmp(s, n));

     return 0;
}

Compiled with gcc 8.2.1 20180831 (Arch) the output is

s = 0x7ffe8771ae51
strcmp(n, s) = 0

--
Allin Cottrell
Department of Economics
Wake Forest University, NC

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: my strstr is broken
  2018-09-11 12:58   ` Allin Cottrell
@ 2018-09-11 13:54     ` Michael Brunnbauer
  2018-09-11 14:21       ` Siddhesh Poyarekar
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Brunnbauer @ 2018-09-11 13:54 UTC (permalink / raw)
  To: Allin Cottrell; +Cc: libc-help

[-- Attachment #1: Type: text/plain, Size: 962 bytes --]


Hello Allin,

On Tue, Sep 11, 2018 at 08:58:07AM -0400, Allin Cottrell wrote:
> Since it's difficult to verify your long strings in email I tried the
> following variant of your test:
[...]
> Compiled with gcc 8.2.1 20180831 (Arch) the output is
> 
> s = 0x7ffe8771ae51
> strcmp(n, s) = 0

I attached my code as file to my first mail. But your program works as well:

s = (nil)
Segmentation fault

Some info about my environment:

Linux Kernel 4.9.124 (recently updated from 3.16)
Glibc 2.28
gcc 7.3.0

cu,
brunni

-- 
++  Michael Brunnbauer
++  netEstate GmbH
++  Geisenhausener Straße 11a
++  81379 München
++  Tel +49 89 32 19 77 80
++  Fax +49 89 32 19 77 89 
++  E-Mail brunni@netestate.de
++  https://www.netestate.de/
++
++  Sitz: München, HRB Nr.142452 (Handelsregister B München)
++  USt-IdNr. DE221033342
++  Geschäftsführer: Michael Brunnbauer, Franz Brunnbauer
++  Prokurist: Dipl. Kfm. (Univ.) Markus Hendel

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 163 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: my strstr is broken
  2018-09-11 13:54     ` Michael Brunnbauer
@ 2018-09-11 14:21       ` Siddhesh Poyarekar
  2018-09-11 14:41         ` Michael Brunnbauer
  0 siblings, 1 reply; 10+ messages in thread
From: Siddhesh Poyarekar @ 2018-09-11 14:21 UTC (permalink / raw)
  To: brunni; +Cc: cottrell, libc-help

On Tue, 11 Sep 2018 at 19:24, Michael Brunnbauer <brunni@netestate.de> wrote:
> I attached my code as file to my first mail. But your program works as well:
>
> s = (nil)
> Segmentation fault
>
> Some info about my environment:
>
> Linux Kernel 4.9.124 (recently updated from 3.16)
> Glibc 2.28
> gcc 7.3.0

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 looks like the test case is fixed on trunk, with[1], but I'll take
a closer look at it later to confirm.

Siddhesh

[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=284f42bc778e487dfd5dff5c01959f93b9e0c4f5

-- 
http://siddhesh.in

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: my strstr is broken
  2018-09-11 14:21       ` Siddhesh Poyarekar
@ 2018-09-11 14:41         ` Michael Brunnbauer
  2018-09-11 14:51           ` Siddhesh Poyarekar
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Brunnbauer @ 2018-09-11 14:41 UTC (permalink / raw)
  To: Siddhesh Poyarekar; +Cc: cottrell, libc-help

[-- Attachment #1: Type: text/plain, Size: 961 bytes --]


Hello Siddhesh,

On Tue, Sep 11, 2018 at 07:51:02PM +0530, Siddhesh Poyarekar wrote:
> Is this a non-x86 architecture?

No it's i686-pc-linux-gnu (output from gcc -dumpmachine).

arch reports x86_64 because the kernel is 64 bit but everything else is 32 bit.

>  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.

So the stock __strstr has a bug?

A 32 bit glibc would not use __strstr_sse2_unaligned, right?

cu,
brunni

-- 
++  Michael Brunnbauer
++  netEstate GmbH
++  Geisenhausener Straße 11a
++  81379 München
++  Tel +49 89 32 19 77 80
++  Fax +49 89 32 19 77 89 
++  E-Mail brunni@netestate.de
++  https://www.netestate.de/
++
++  Sitz: München, HRB Nr.142452 (Handelsregister B München)
++  USt-IdNr. DE221033342
++  Geschäftsführer: Michael Brunnbauer, Franz Brunnbauer
++  Prokurist: Dipl. Kfm. (Univ.) Markus Hendel

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 163 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: my strstr is broken
  2018-09-11 14:41         ` Michael Brunnbauer
@ 2018-09-11 14:51           ` Siddhesh Poyarekar
  2018-09-11 15:21             ` Paul Pluzhnikov via libc-help
  0 siblings, 1 reply; 10+ messages in thread
From: Siddhesh Poyarekar @ 2018-09-11 14:51 UTC (permalink / raw)
  To: brunni; +Cc: cottrell, libc-help

On Tue, 11 Sep 2018 at 20:11, Michael Brunnbauer <brunni@netestate.de> wrote:
> No it's i686-pc-linux-gnu (output from gcc -dumpmachine).
>
> arch reports x86_64 because the kernel is 64 bit but everything else is 32 bit.
>
> >  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.
>
> So the stock __strstr has a bug?
>
> A 32 bit glibc would not use __strstr_sse2_unaligned, right?

Right, my question should have been 'non-x86_64' I flew back ~5 time
zones this morning and my brain's still a bit mushy, sorry :)

The stock __strstr has a bug, which seems to have been fixed on master
with the commit I mentioned.  I'll need to vet it to make sure that
the fix is not just incidental and that the root cause (which I
haven't understood yet, jet lag, etc.) is also fixed and then backport
it to the 2.28 branch.

Siddhesh


-- 
http://siddhesh.in

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: my strstr is broken
  2018-09-11 14:51           ` Siddhesh Poyarekar
@ 2018-09-11 15:21             ` Paul Pluzhnikov via libc-help
  2018-09-11 15:38               ` Siddhesh Poyarekar
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Pluzhnikov via libc-help @ 2018-09-11 15:21 UTC (permalink / raw)
  To: Siddhesh Poyarekar; +Cc: brunni, cottrell, libc-help, GLIBC Devel

+cc libc-alpha

On Tue, Sep 11, 2018 at 7:51 AM Siddhesh Poyarekar
<siddhesh.poyarekar@gmail.com> wrote:

> The stock __strstr has a bug, which seems to have been fixed on master
> with the commit I mentioned.

This is the second time in my (short) memory strstr got broken with
very long inputs
(https://sourceware.org/bugzilla/show_bug.cgi?id=12092).
There was also https://sourceware.org/bugzilla/show_bug.cgi?id=14602

It seems that testing of strstr is entirely inadequate: (AFAICT) we
only test the IFUNC-selected version, and only on small set of inputs.

I filed https://sourceware.org/bugzilla/show_bug.cgi?id=23631


-- 
Paul Pluzhnikov

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: my strstr is broken
  2018-09-11 15:21             ` Paul Pluzhnikov via libc-help
@ 2018-09-11 15:38               ` Siddhesh Poyarekar
  0 siblings, 0 replies; 10+ messages in thread
From: Siddhesh Poyarekar @ 2018-09-11 15:38 UTC (permalink / raw)
  To: Paul Pluzhnikov; +Cc: brunni, cottrell, libc-help, GLIBC Devel

On Tuesday 11 September 2018 08:51 PM, Paul Pluzhnikov wrote:
> This is the second time in my (short) memory strstr got broken with
> very long inputs
> (https://sourceware.org/bugzilla/show_bug.cgi?id=12092).
> There was also https://sourceware.org/bugzilla/show_bug.cgi?id=14602
> 
> It seems that testing of strstr is entirely inadequate: (AFAICT) we
> only test the IFUNC-selected version, and only on small set of inputs.

I'm not sure about the assertion about not testing IFUNC versions (since 
only x86_64 and powerpc seem to be using them and their IFUNC_IMPL 
macros look correct to me and should trigger all variants provided the 
hardware supports it) but a stress test would be most welcome.

Thanks,
Siddhesh

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: my strstr is broken
@ 2018-09-11 18:46 Wilco Dijkstra
  0 siblings, 0 replies; 10+ messages in thread
From: Wilco Dijkstra @ 2018-09-11 18:46 UTC (permalink / raw)
  To: siddhesh.poyarekar; +Cc: brunni, cottrell, libc-alpha, libc-help, nd

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.

> It looks like the test case is fixed on trunk, with[1], but I'll take
> a closer look at it later to confirm.

No it still exists on trunk, but you need avoid tests with a trivial first match
which is now handled early as a special case. Also to make it fail consistently
the needle needs to be longer than 1024 characters. Unfortunately neither the
tests or benchmarks ever call two_way_long_needle...

Wilco

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-09-11 18:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-10 14:47 my strstr is broken Michael Brunnbauer
2018-09-11 10:27 ` Michael Brunnbauer
2018-09-11 12:58   ` Allin Cottrell
2018-09-11 13:54     ` Michael Brunnbauer
2018-09-11 14:21       ` Siddhesh Poyarekar
2018-09-11 14:41         ` Michael Brunnbauer
2018-09-11 14:51           ` Siddhesh Poyarekar
2018-09-11 15:21             ` Paul Pluzhnikov via libc-help
2018-09-11 15:38               ` Siddhesh Poyarekar
2018-09-11 18:46 Wilco Dijkstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).