public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Re: [PATCH v2] stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265]
       [not found] <7a0d8978-3774-49d6-a7d5-130c3268a5b6gotplt!org>
@ 2022-06-22 20:56 ` Mark Wielaard
  2022-06-22 21:38   ` Noah Goldstein
  0 siblings, 1 reply; 11+ messages in thread
From: Mark Wielaard @ 2022-06-22 20:56 UTC (permalink / raw)
  To: Siddhesh Poyarekar; +Cc: libc-alpha, Noah Goldstein

Hi,

(Sorry for the duplicate, got the mailinglist name wrong)

On Wed, Jun 22, 2022 at 03:42:43PM +0000, Siddhesh Poyarekar wrote:
> On 22/06/2022 20:54, Noah Goldstein via Libc-alpha wrote:
> > mbstows is defined if dst is NULL and is defined to special cased if
> > dst is NULL so the fortify objsize check if incorrect in that case.
> > 
> > Tested on x86-64 linux.
> > ---
> >   stdlib/Makefile      |  3 +++
> >   stdlib/bits/stdlib.h | 16 +++++++++++-----
> >   stdlib/testmb.c      |  7 +++++++
> >   3 files changed, 21 insertions(+), 5 deletions(-)
> 
> LGTM.
> 
> Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

This broke make check for me on Fedora 35 with gcc (GCC) 11.3.1
20220421 (Red Hat 11.3.1-2)

gcc -o /srv/glibc/glibc-obj/stdlib/testmb -pie  -Wl,-O1 -nostdlib -nostartfiles    -Wl,-z,relro  /srv/glibc/glibc-obj/csu/Scrt1.o /srv/glibc/glibc-obj/csu/crti.o `gcc  --print-file-name=crtbeginS.o` /srv/glibc/glibc-obj/stdlib/testmb.o /srv/glibc/glibc-obj/support/libsupport_nonshared.a  -Wl,-dynamic-linker=/lib64/ld-linux-x86-64.so.2 -Wl,-rpath-link=/srv/glibc/glibc-obj:/srv/glibc/glibc-obj/math:/srv/glibc/glibc-obj/elf:/srv/glibc/glibc-obj/dlfcn:/srv/glibc/glibc-obj/nss:/srv/glibc/glibc-obj/nis:/srv/glibc/glibc-obj/rt:/srv/glibc/glibc-obj/resolv:/srv/glibc/glibc-obj/mathvec:/srv/glibc/glibc-obj/support:/srv/glibc/glibc-obj/crypt:/srv/glibc/glibc-obj/nptl -lgcc -Wl,--as-needed -lgcc_s  -Wl,--no-as-needed /srv/glibc/glibc-obj/libc.so.6 /srv/glibc/glibc-obj/libc_nonshared.a -Wl,--as-needed /srv/glibc/glibc-obj/elf/ld.so -Wl,--no-as-needed -lgcc -Wl,--as-needed -lgcc_s  -Wl,--no-as-needed `gcc  --print-file-name=crtendS.o` /srv/glibc/glibc-obj/csu/crtn.o
/usr/bin/ld: /srv/glibc/glibc-obj/stdlib/testmb.o: in function `mbstowcs':
/srv/glibc/glibc/stdlib/../stdlib/bits/stdlib.h:121: undefined reference to `mbstowcs_chk'
collect2: error: ld returned 1 exit status
make[2]: *** [../Rules:238: /srv/glibc/glibc-obj/stdlib/testmb] Error 1

It looks like that mbstowcs_chk should be __mbstowcs_chk

diff --git a/stdlib/bits/stdlib.h b/stdlib/bits/stdlib.h
index d9c2d822a5..a0c4996614 100644
--- a/stdlib/bits/stdlib.h
+++ b/stdlib/bits/stdlib.h
@@ -99,7 +99,7 @@ extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
 extern size_t __REDIRECT_NTH (__mbstowcs_chk_nulldst,
                              (wchar_t *__restrict __dst,
                               const char *__restrict __src,
-                              size_t __len), mbstowcs_chk)
+                              size_t __len), __mbstowcs_chk)
     __attr_access ((__read_only__, 2));
 extern size_t __REDIRECT_NTH (__mbstowcs_alias,
                              (wchar_t *__restrict __dst,

Which makes it compile, but then the stdlib/testmb testcase fails.

Cheers,

Mark


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

* Re: [PATCH v2] stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265]
  2022-06-22 20:56 ` [PATCH v2] stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265] Mark Wielaard
@ 2022-06-22 21:38   ` Noah Goldstein
  2022-06-22 22:06     ` Mark Wielaard
  0 siblings, 1 reply; 11+ messages in thread
From: Noah Goldstein @ 2022-06-22 21:38 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: Siddhesh Poyarekar, GNU C Library

On Wed, Jun 22, 2022 at 1:56 PM Mark Wielaard <mark@klomp.org> wrote:
>
> Hi,
>
> (Sorry for the duplicate, got the mailinglist name wrong)
>
> On Wed, Jun 22, 2022 at 03:42:43PM +0000, Siddhesh Poyarekar wrote:
> > On 22/06/2022 20:54, Noah Goldstein via Libc-alpha wrote:
> > > mbstows is defined if dst is NULL and is defined to special cased if
> > > dst is NULL so the fortify objsize check if incorrect in that case.
> > >
> > > Tested on x86-64 linux.
> > > ---
> > >   stdlib/Makefile      |  3 +++
> > >   stdlib/bits/stdlib.h | 16 +++++++++++-----
> > >   stdlib/testmb.c      |  7 +++++++
> > >   3 files changed, 21 insertions(+), 5 deletions(-)
> >
> > LGTM.
> >
> > Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
>
> This broke make check for me on Fedora 35 with gcc (GCC) 11.3.1
> 20220421 (Red Hat 11.3.1-2)
>
> gcc -o /srv/glibc/glibc-obj/stdlib/testmb -pie  -Wl,-O1 -nostdlib -nostartfiles    -Wl,-z,relro  /srv/glibc/glibc-obj/csu/Scrt1.o /srv/glibc/glibc-obj/csu/crti.o `gcc  --print-file-name=crtbeginS.o` /srv/glibc/glibc-obj/stdlib/testmb.o /srv/glibc/glibc-obj/support/libsupport_nonshared.a  -Wl,-dynamic-linker=/lib64/ld-linux-x86-64.so.2 -Wl,-rpath-link=/srv/glibc/glibc-obj:/srv/glibc/glibc-obj/math:/srv/glibc/glibc-obj/elf:/srv/glibc/glibc-obj/dlfcn:/srv/glibc/glibc-obj/nss:/srv/glibc/glibc-obj/nis:/srv/glibc/glibc-obj/rt:/srv/glibc/glibc-obj/resolv:/srv/glibc/glibc-obj/mathvec:/srv/glibc/glibc-obj/support:/srv/glibc/glibc-obj/crypt:/srv/glibc/glibc-obj/nptl -lgcc -Wl,--as-needed -lgcc_s  -Wl,--no-as-needed /srv/glibc/glibc-obj/libc.so.6 /srv/glibc/glibc-obj/libc_nonshared.a -Wl,--as-needed /srv/glibc/glibc-obj/elf/ld.so -Wl,--no-as-needed -lgcc -Wl,--as-needed -lgcc_s  -Wl,--no-as-needed `gcc  --print-file-name=crtendS.o` /srv/glibc/glibc-obj/csu/crtn.o
> /usr/bin/ld: /srv/glibc/glibc-obj/stdlib/testmb.o: in function `mbstowcs':
> /srv/glibc/glibc/stdlib/../stdlib/bits/stdlib.h:121: undefined reference to `mbstowcs_chk'
> collect2: error: ld returned 1 exit status
> make[2]: *** [../Rules:238: /srv/glibc/glibc-obj/stdlib/testmb] Error 1
>
> It looks like that mbstowcs_chk should be __mbstowcs_chk
>
> diff --git a/stdlib/bits/stdlib.h b/stdlib/bits/stdlib.h
> index d9c2d822a5..a0c4996614 100644
> --- a/stdlib/bits/stdlib.h
> +++ b/stdlib/bits/stdlib.h
> @@ -99,7 +99,7 @@ extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
>  extern size_t __REDIRECT_NTH (__mbstowcs_chk_nulldst,
>                               (wchar_t *__restrict __dst,
>                                const char *__restrict __src,
> -                              size_t __len), mbstowcs_chk)
> +                              size_t __len), __mbstowcs_chk)
>      __attr_access ((__read_only__, 2));
>  extern size_t __REDIRECT_NTH (__mbstowcs_alias,
>                               (wchar_t *__restrict __dst,
>
> Which makes it compile, but then the stdlib/testmb testcase fails.

I think it should be just mbstowcs, we don't pass dstlen

Does:

```
diff --git a/stdlib/bits/stdlib.h b/stdlib/bits/stdlib.h
index d9c2d822a5..ece553df74 100644
--- a/stdlib/bits/stdlib.h
+++ b/stdlib/bits/stdlib.h
@@ -96,10 +96,10 @@ extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
        const char *__restrict __src,
        size_t __len, size_t __dstlen) __THROW
     __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
-extern size_t __REDIRECT_NTH (__mbstowcs_chk_nulldst,
+extern size_t __REDIRECT_NTH (__mbstowcs_nulldst,
        (wchar_t *__restrict __dst,
         const char *__restrict __src,
-        size_t __len), mbstowcs_chk)
+        size_t __len), mbstowcs)
     __attr_access ((__read_only__, 2));
 extern size_t __REDIRECT_NTH (__mbstowcs_alias,
        (wchar_t *__restrict __dst,
@@ -118,7 +118,7 @@ __NTH (mbstowcs (wchar_t *__restrict __dst, const
char *__restrict __src,
  size_t __len))
 {
   if (__builtin_constant_p (__dst == NULL) && __dst == NULL)
-    return __mbstowcs_chk_nulldst (__dst, __src, __len);
+    return __mbstowcs_nulldst (__dst, __src, __len);
   else
     return __glibc_fortify_n (mbstowcs, __len, sizeof (wchar_t),
        __glibc_objsize (__dst), __dst, __src, __len);
```

Work?
>
> Cheers,
>
> Mark
>

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

* Re: [PATCH v2] stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265]
  2022-06-22 21:38   ` Noah Goldstein
@ 2022-06-22 22:06     ` Mark Wielaard
  2022-06-22 22:34       ` Noah Goldstein
  2022-06-22 22:38       ` Noah Goldstein
  0 siblings, 2 replies; 11+ messages in thread
From: Mark Wielaard @ 2022-06-22 22:06 UTC (permalink / raw)
  To: Noah Goldstein; +Cc: Siddhesh Poyarekar, GNU C Library

Hi Noah,

On Wed, Jun 22, 2022 at 02:38:07PM -0700, Noah Goldstein wrote:
> I think it should be just mbstowcs, we don't pass dstlen
> 
> Does:
> 
> ```
> diff --git a/stdlib/bits/stdlib.h b/stdlib/bits/stdlib.h
> index d9c2d822a5..ece553df74 100644
> --- a/stdlib/bits/stdlib.h
> +++ b/stdlib/bits/stdlib.h
> @@ -96,10 +96,10 @@ extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
>         const char *__restrict __src,
>         size_t __len, size_t __dstlen) __THROW
>      __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
> -extern size_t __REDIRECT_NTH (__mbstowcs_chk_nulldst,
> +extern size_t __REDIRECT_NTH (__mbstowcs_nulldst,
>         (wchar_t *__restrict __dst,
>          const char *__restrict __src,
> -        size_t __len), mbstowcs_chk)
> +        size_t __len), mbstowcs)
>      __attr_access ((__read_only__, 2));
>  extern size_t __REDIRECT_NTH (__mbstowcs_alias,
>         (wchar_t *__restrict __dst,
> @@ -118,7 +118,7 @@ __NTH (mbstowcs (wchar_t *__restrict __dst, const
> char *__restrict __src,
>   size_t __len))
>  {
>    if (__builtin_constant_p (__dst == NULL) && __dst == NULL)
> -    return __mbstowcs_chk_nulldst (__dst, __src, __len);
> +    return __mbstowcs_nulldst (__dst, __src, __len);
>    else
>      return __glibc_fortify_n (mbstowcs, __len, sizeof (wchar_t),
>         __glibc_objsize (__dst), __dst, __src, __len);
> ```
> 
> Work?

I hope I applied to correctly, there were some whitespace issues.
But no, that causes:

make[2]: Entering directory '/srv/glibc/glibc/debug'
g++ /srv/glibc/glibc-obj/debug/tst-fortify-cc-default-1.cc -c -I/srv/glibc/glibc-obj/  -g -O2 -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -fno-common   -fpie -D_FORTIFY_SOURCE=1 -Wno-format -Wno-deprecated-declarations -Wno-error      -I../include -I/srv/glibc/glibc-obj/debug  -I/srv/glibc/glibc-obj  -I../sysdeps/unix/sysv/linux/x86_64/64  -I../sysdeps/unix/sysv/linux/x86_64  -I../sysdeps/unix/sysv/linux/x86/include -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/x86/nptl  -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/x86_64  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch  -I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu  -I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64  -I../sysdeps/x86/include -I../sysdeps/x86  -I../sysdeps/ieee754/float128  -I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I.  -D_LIBC_REENTRANT -include /srv/glibc/glibc-obj/libc-modules.h -DMODULE_NAME=testsuite -include ../include/libc-symbols.h  -DPIC     -DTOP_NAMESPACE=glibc -o /srv/glibc/glibc-obj/debug/tst-fortify-cc-default-1.o -MD -MP -MF /srv/glibc/glibc-obj/debug/tst-fortify-cc-default-1.o.dt -MT /srv/glibc/glibc-obj/debug/tst-fortify-cc-default-1.o
In file included from ../include/sys/cdefs.h:10,
                 from ../include/features.h:490,
                 from ./tst-fortify.c:20,
                 from /srv/glibc/glibc-obj/debug/tst-fortify-cc-default-1.cc:3:
../misc/sys/cdefs.h:424:26: error: duplicate ‘inline’
  424 | # define __always_inline __inline __attribute__ ((__always_inline__))
      |                          ^~~~~~~~
../misc/sys/cdefs.h:453:10: note: in expansion of macro ‘__always_inline’
  453 |   extern __always_inline __attribute__ ((__gnu_inline__))
      |          ^~~~~~~~~~~~~~~
../misc/sys/cdefs.h:461:29: note: in expansion of macro ‘__extern_always_inline’
  461 | # define __fortify_function __extern_always_inline __attribute_artificial__
      |                             ^~~~~~~~~~~~~~~~~~~~~~
../stdlib/bits/stdlib.h:116:17: note: in expansion of macro ‘__fortify_function’
  116 | __always_inline __fortify_function size_t
      |                 ^~~~~~~~~~~~~~~~~~
make[2]: *** [../o-iterator.mk:9: /srv/glibc/glibc-obj/debug/tst-fortify-cc-default-1.o] Error 1

I am afraid I am a little lost in the macro expansions that cause the
duplicate inline here.

Cheers,

Mark


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

* Re: [PATCH v2] stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265]
  2022-06-22 22:06     ` Mark Wielaard
@ 2022-06-22 22:34       ` Noah Goldstein
  2022-06-22 22:45         ` Mark Wielaard
  2022-06-22 22:38       ` Noah Goldstein
  1 sibling, 1 reply; 11+ messages in thread
From: Noah Goldstein @ 2022-06-22 22:34 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: Siddhesh Poyarekar, GNU C Library

On Wed, Jun 22, 2022 at 3:06 PM Mark Wielaard <mark@klomp.org> wrote:
>
> Hi Noah,
>
> On Wed, Jun 22, 2022 at 02:38:07PM -0700, Noah Goldstein wrote:
> > I think it should be just mbstowcs, we don't pass dstlen
> >
> > Does:
> >
> > ```
> > diff --git a/stdlib/bits/stdlib.h b/stdlib/bits/stdlib.h
> > index d9c2d822a5..ece553df74 100644
> > --- a/stdlib/bits/stdlib.h
> > +++ b/stdlib/bits/stdlib.h
> > @@ -96,10 +96,10 @@ extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
> >         const char *__restrict __src,
> >         size_t __len, size_t __dstlen) __THROW
> >      __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
> > -extern size_t __REDIRECT_NTH (__mbstowcs_chk_nulldst,
> > +extern size_t __REDIRECT_NTH (__mbstowcs_nulldst,
> >         (wchar_t *__restrict __dst,
> >          const char *__restrict __src,
> > -        size_t __len), mbstowcs_chk)
> > +        size_t __len), mbstowcs)
> >      __attr_access ((__read_only__, 2));
> >  extern size_t __REDIRECT_NTH (__mbstowcs_alias,
> >         (wchar_t *__restrict __dst,
> > @@ -118,7 +118,7 @@ __NTH (mbstowcs (wchar_t *__restrict __dst, const
> > char *__restrict __src,
> >   size_t __len))
> >  {
> >    if (__builtin_constant_p (__dst == NULL) && __dst == NULL)
> > -    return __mbstowcs_chk_nulldst (__dst, __src, __len);
> > +    return __mbstowcs_nulldst (__dst, __src, __len);
> >    else
> >      return __glibc_fortify_n (mbstowcs, __len, sizeof (wchar_t),
> >         __glibc_objsize (__dst), __dst, __src, __len);
> > ```
> >
> > Work?
>
> I hope I applied to correctly, there were some whitespace issues.
> But no, that causes:
>
> make[2]: Entering directory '/srv/glibc/glibc/debug'
> g++ /srv/glibc/glibc-obj/debug/tst-fortify-cc-default-1.cc -c -I/srv/glibc/glibc-obj/  -g -O2 -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -fno-common   -fpie -D_FORTIFY_SOURCE=1 -Wno-format -Wno-deprecated-declarations -Wno-error      -I../include -I/srv/glibc/glibc-obj/debug  -I/srv/glibc/glibc-obj  -I../sysdeps/unix/sysv/linux/x86_64/64  -I../sysdeps/unix/sysv/linux/x86_64  -I../sysdeps/unix/sysv/linux/x86/include -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/x86/nptl  -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/x86_64  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch  -I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu  -I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64  -I../sysdeps/x86/include -I../sysdeps/x86  -I../sysdeps/ieee754/float128  -I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I.  -D_LIBC_REENTRANT -include /srv/glibc/glibc-obj/libc-modules.h -DMODULE_NAME=testsuite -include ../include/libc-symbols.h  -DPIC     -DTOP_NAMESPACE=glibc -o /srv/glibc/glibc-obj/debug/tst-fortify-cc-default-1.o -MD -MP -MF /srv/glibc/glibc-obj/debug/tst-fortify-cc-default-1.o.dt -MT /srv/glibc/glibc-obj/debug/tst-fortify-cc-default-1.o
> In file included from ../include/sys/cdefs.h:10,
>                  from ../include/features.h:490,
>                  from ./tst-fortify.c:20,
>                  from /srv/glibc/glibc-obj/debug/tst-fortify-cc-default-1.cc:3:
> ../misc/sys/cdefs.h:424:26: error: duplicate ‘inline’
>   424 | # define __always_inline __inline __attribute__ ((__always_inline__))
>       |                          ^~~~~~~~
> ../misc/sys/cdefs.h:453:10: note: in expansion of macro ‘__always_inline’
>   453 |   extern __always_inline __attribute__ ((__gnu_inline__))
>       |          ^~~~~~~~~~~~~~~
> ../misc/sys/cdefs.h:461:29: note: in expansion of macro ‘__extern_always_inline’
>   461 | # define __fortify_function __extern_always_inline __attribute_artificial__
>       |                             ^~~~~~~~~~~~~~~~~~~~~~
> ../stdlib/bits/stdlib.h:116:17: note: in expansion of macro ‘__fortify_function’
>   116 | __always_inline __fortify_function size_t
>       |                 ^~~~~~~~~~~~~~~~~~
> make[2]: *** [../o-iterator.mk:9: /srv/glibc/glibc-obj/debug/tst-fortify-cc-default-1.o] Error 1
>
> I am afraid I am a little lost in the macro expansions that cause the
> duplicate inline here.

What configure flags did you pass when building glibc?
>
> Cheers,
>
> Mark
>

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

* Re: [PATCH v2] stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265]
  2022-06-22 22:06     ` Mark Wielaard
  2022-06-22 22:34       ` Noah Goldstein
@ 2022-06-22 22:38       ` Noah Goldstein
  2022-06-22 23:16         ` Mark Wielaard
  1 sibling, 1 reply; 11+ messages in thread
From: Noah Goldstein @ 2022-06-22 22:38 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: Siddhesh Poyarekar, GNU C Library

On Wed, Jun 22, 2022 at 3:06 PM Mark Wielaard <mark@klomp.org> wrote:
>
> Hi Noah,
>
> On Wed, Jun 22, 2022 at 02:38:07PM -0700, Noah Goldstein wrote:
> > I think it should be just mbstowcs, we don't pass dstlen
> >
> > Does:
> >
> > ```
> > diff --git a/stdlib/bits/stdlib.h b/stdlib/bits/stdlib.h
> > index d9c2d822a5..ece553df74 100644
> > --- a/stdlib/bits/stdlib.h
> > +++ b/stdlib/bits/stdlib.h
> > @@ -96,10 +96,10 @@ extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
> >         const char *__restrict __src,
> >         size_t __len, size_t __dstlen) __THROW
> >      __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
> > -extern size_t __REDIRECT_NTH (__mbstowcs_chk_nulldst,
> > +extern size_t __REDIRECT_NTH (__mbstowcs_nulldst,
> >         (wchar_t *__restrict __dst,
> >          const char *__restrict __src,
> > -        size_t __len), mbstowcs_chk)
> > +        size_t __len), mbstowcs)
> >      __attr_access ((__read_only__, 2));
> >  extern size_t __REDIRECT_NTH (__mbstowcs_alias,
> >         (wchar_t *__restrict __dst,
> > @@ -118,7 +118,7 @@ __NTH (mbstowcs (wchar_t *__restrict __dst, const
> > char *__restrict __src,
> >   size_t __len))
> >  {
> >    if (__builtin_constant_p (__dst == NULL) && __dst == NULL)
> > -    return __mbstowcs_chk_nulldst (__dst, __src, __len);
> > +    return __mbstowcs_nulldst (__dst, __src, __len);
> >    else
> >      return __glibc_fortify_n (mbstowcs, __len, sizeof (wchar_t),
> >         __glibc_objsize (__dst), __dst, __src, __len);
> > ```
> >
> > Work?
>
> I hope I applied to correctly, there were some whitespace issues.
> But no, that causes:
>
> make[2]: Entering directory '/srv/glibc/glibc/debug'
> g++ /srv/glibc/glibc-obj/debug/tst-fortify-cc-default-1.cc -c -I/srv/glibc/glibc-obj/  -g -O2 -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -fno-common   -fpie -D_FORTIFY_SOURCE=1 -Wno-format -Wno-deprecated-declarations -Wno-error      -I../include -I/srv/glibc/glibc-obj/debug  -I/srv/glibc/glibc-obj  -I../sysdeps/unix/sysv/linux/x86_64/64  -I../sysdeps/unix/sysv/linux/x86_64  -I../sysdeps/unix/sysv/linux/x86/include -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/x86/nptl  -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/x86_64  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch  -I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu  -I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64  -I../sysdeps/x86/include -I../sysdeps/x86  -I../sysdeps/ieee754/float128  -I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I.  -D_LIBC_REENTRANT -include /srv/glibc/glibc-obj/libc-modules.h -DMODULE_NAME=testsuite -include ../include/libc-symbols.h  -DPIC     -DTOP_NAMESPACE=glibc -o /srv/glibc/glibc-obj/debug/tst-fortify-cc-default-1.o -MD -MP -MF /srv/glibc/glibc-obj/debug/tst-fortify-cc-default-1.o.dt -MT /srv/glibc/glibc-obj/debug/tst-fortify-cc-default-1.o
> In file included from ../include/sys/cdefs.h:10,
>                  from ../include/features.h:490,
>                  from ./tst-fortify.c:20,
>                  from /srv/glibc/glibc-obj/debug/tst-fortify-cc-default-1.cc:3:
> ../misc/sys/cdefs.h:424:26: error: duplicate ‘inline’
>   424 | # define __always_inline __inline __attribute__ ((__always_inline__))
>       |                          ^~~~~~~~
> ../misc/sys/cdefs.h:453:10: note: in expansion of macro ‘__always_inline’
>   453 |   extern __always_inline __attribute__ ((__gnu_inline__))
>       |          ^~~~~~~~~~~~~~~
> ../misc/sys/cdefs.h:461:29: note: in expansion of macro ‘__extern_always_inline’
>   461 | # define __fortify_function __extern_always_inline __attribute_artificial__
>       |                             ^~~~~~~~~~~~~~~~~~~~~~
> ../stdlib/bits/stdlib.h:116:17: note: in expansion of macro ‘__fortify_function’
>   116 | __always_inline __fortify_function size_t
>       |                 ^~~~~~~~~~~~~~~~~~
> make[2]: *** [../o-iterator.mk:9: /srv/glibc/glibc-obj/debug/tst-fortify-cc-default-1.o] Error 1
>
> I am afraid I am a little lost in the macro expansions that cause the
> duplicate inline here.
>
> Cheers,
>
> Mark
>

Seems the issue is the extra __always_inline:

```
diff --git a/stdlib/bits/stdlib.h b/stdlib/bits/stdlib.h
index d9c2d822a5..de1c3b20f0 100644
--- a/stdlib/bits/stdlib.h
+++ b/stdlib/bits/stdlib.h
@@ -96,10 +96,10 @@ extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
        const char *__restrict __src,
        size_t __len, size_t __dstlen) __THROW
     __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
-extern size_t __REDIRECT_NTH (__mbstowcs_chk_nulldst,
+extern size_t __REDIRECT_NTH (__mbstowcs_nulldst,
        (wchar_t *__restrict __dst,
         const char *__restrict __src,
-        size_t __len), mbstowcs_chk)
+        size_t __len), mbstowcs)
     __attr_access ((__read_only__, 2));
 extern size_t __REDIRECT_NTH (__mbstowcs_alias,
        (wchar_t *__restrict __dst,
@@ -113,12 +113,12 @@ extern size_t __REDIRECT_NTH (__mbstowcs_chk_warn,
      __warnattr ("mbstowcs called with dst buffer smaller than len "
  "* sizeof (wchar_t)");

-__always_inline __fortify_function size_t
+__fortify_function size_t
 __NTH (mbstowcs (wchar_t *__restrict __dst, const char *__restrict __src,
  size_t __len))
 {
   if (__builtin_constant_p (__dst == NULL) && __dst == NULL)
-    return __mbstowcs_chk_nulldst (__dst, __src, __len);
+    return __mbstowcs_nulldst (__dst, __src, __len);
   else
     return __glibc_fortify_n (mbstowcs, __len, sizeof (wchar_t),
        __glibc_objsize (__dst), __dst, __src, __len);
```

can you try this. I am totally unable to reproduce this but its obviously a bug.

What build flags are you using? Whatever I have is insufficient.

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

* Re: [PATCH v2] stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265]
  2022-06-22 22:34       ` Noah Goldstein
@ 2022-06-22 22:45         ` Mark Wielaard
  2022-06-22 23:02           ` Noah Goldstein
  0 siblings, 1 reply; 11+ messages in thread
From: Mark Wielaard @ 2022-06-22 22:45 UTC (permalink / raw)
  To: Noah Goldstein; +Cc: Siddhesh Poyarekar, GNU C Library

Hi Noah,

On Wed, Jun 22, 2022 at 03:34:26PM -0700, Noah Goldstein wrote:
> > I am afraid I am a little lost in the macro expansions that cause the
> > duplicate inline here.
> 
> What configure flags did you pass when building glibc?

Just ../glibc/configure --prefix=/usr

BTW. Reverting commit 464d189b9622932a75302290625de84931656ec0
"stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265]"
make -j8 && make check -j8 builds and has no FAILs.

Summary of test results:
   5067 PASS
     76 UNSUPPORTED
     18 XFAIL
      4 XPASS

Cheers,

Mark


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

* Re: [PATCH v2] stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265]
  2022-06-22 22:45         ` Mark Wielaard
@ 2022-06-22 23:02           ` Noah Goldstein
  0 siblings, 0 replies; 11+ messages in thread
From: Noah Goldstein @ 2022-06-22 23:02 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: Siddhesh Poyarekar, GNU C Library

On Wed, Jun 22, 2022 at 3:45 PM Mark Wielaard <mark@klomp.org> wrote:
>
> Hi Noah,
>
> On Wed, Jun 22, 2022 at 03:34:26PM -0700, Noah Goldstein wrote:
> > > I am afraid I am a little lost in the macro expansions that cause the
> > > duplicate inline here.
> >
> > What configure flags did you pass when building glibc?
>
> Just ../glibc/configure --prefix=/usr
>
> BTW. Reverting commit 464d189b9622932a75302290625de84931656ec0
> "stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265]"
> make -j8 && make check -j8 builds and has no FAILs.
>
> Summary of test results:
>    5067 PASS
>      76 UNSUPPORTED
>      18 XFAIL
>       4 XPASS
>
> Cheers,

If the patch the fixes the inline issue works then we can use that.
Otherwise fine with reverting.

>
> Mark
>

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

* Re: [PATCH v2] stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265]
  2022-06-22 22:38       ` Noah Goldstein
@ 2022-06-22 23:16         ` Mark Wielaard
  2022-06-22 23:30           ` Noah Goldstein
  0 siblings, 1 reply; 11+ messages in thread
From: Mark Wielaard @ 2022-06-22 23:16 UTC (permalink / raw)
  To: Noah Goldstein; +Cc: Siddhesh Poyarekar, GNU C Library

Hi Noah,

On Wed, Jun 22, 2022 at 03:38:02PM -0700, Noah Goldstein wrote:
> Seems the issue is the extra __always_inline:
> 
> ```
> diff --git a/stdlib/bits/stdlib.h b/stdlib/bits/stdlib.h
> index d9c2d822a5..de1c3b20f0 100644
> --- a/stdlib/bits/stdlib.h
> +++ b/stdlib/bits/stdlib.h
> @@ -96,10 +96,10 @@ extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
>         const char *__restrict __src,
>         size_t __len, size_t __dstlen) __THROW
>      __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
> -extern size_t __REDIRECT_NTH (__mbstowcs_chk_nulldst,
> +extern size_t __REDIRECT_NTH (__mbstowcs_nulldst,
>         (wchar_t *__restrict __dst,
>          const char *__restrict __src,
> -        size_t __len), mbstowcs_chk)
> +        size_t __len), mbstowcs)
>      __attr_access ((__read_only__, 2));
>  extern size_t __REDIRECT_NTH (__mbstowcs_alias,
>         (wchar_t *__restrict __dst,
> @@ -113,12 +113,12 @@ extern size_t __REDIRECT_NTH (__mbstowcs_chk_warn,
>       __warnattr ("mbstowcs called with dst buffer smaller than len "
>   "* sizeof (wchar_t)");
> 
> -__always_inline __fortify_function size_t
> +__fortify_function size_t
>  __NTH (mbstowcs (wchar_t *__restrict __dst, const char *__restrict __src,
>   size_t __len))
>  {
>    if (__builtin_constant_p (__dst == NULL) && __dst == NULL)
> -    return __mbstowcs_chk_nulldst (__dst, __src, __len);
> +    return __mbstowcs_nulldst (__dst, __src, __len);
>    else
>      return __glibc_fortify_n (mbstowcs, __len, sizeof (wchar_t),
>         __glibc_objsize (__dst), __dst, __src, __len);
> ```
> 
> can you try this. I am totally unable to reproduce this but its obviously a bug.

That works (modulo tab/space)

Summary of test results:
   5067 PASS
     76 UNSUPPORTED
     18 XFAIL
      4 XPASS

Thanks!

> What build flags are you using? Whatever I have is insufficient.

Nothing. Really just:
../glibc/configure --prefix=/usr && make -j8 && make check -j8

This is a fairly standard Fedora 35 install.
glibc 2.34.
gcc 11.3.1
binutils 2.37

Cheers,

Mark


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

* Re: [PATCH v2] stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265]
  2022-06-22 23:16         ` Mark Wielaard
@ 2022-06-22 23:30           ` Noah Goldstein
  0 siblings, 0 replies; 11+ messages in thread
From: Noah Goldstein @ 2022-06-22 23:30 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: Siddhesh Poyarekar, GNU C Library

On Wed, Jun 22, 2022 at 4:16 PM Mark Wielaard <mark@klomp.org> wrote:
>
> Hi Noah,
>
> On Wed, Jun 22, 2022 at 03:38:02PM -0700, Noah Goldstein wrote:
> > Seems the issue is the extra __always_inline:
> >
> > ```
> > diff --git a/stdlib/bits/stdlib.h b/stdlib/bits/stdlib.h
> > index d9c2d822a5..de1c3b20f0 100644
> > --- a/stdlib/bits/stdlib.h
> > +++ b/stdlib/bits/stdlib.h
> > @@ -96,10 +96,10 @@ extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
> >         const char *__restrict __src,
> >         size_t __len, size_t __dstlen) __THROW
> >      __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
> > -extern size_t __REDIRECT_NTH (__mbstowcs_chk_nulldst,
> > +extern size_t __REDIRECT_NTH (__mbstowcs_nulldst,
> >         (wchar_t *__restrict __dst,
> >          const char *__restrict __src,
> > -        size_t __len), mbstowcs_chk)
> > +        size_t __len), mbstowcs)
> >      __attr_access ((__read_only__, 2));
> >  extern size_t __REDIRECT_NTH (__mbstowcs_alias,
> >         (wchar_t *__restrict __dst,
> > @@ -113,12 +113,12 @@ extern size_t __REDIRECT_NTH (__mbstowcs_chk_warn,
> >       __warnattr ("mbstowcs called with dst buffer smaller than len "
> >   "* sizeof (wchar_t)");
> >
> > -__always_inline __fortify_function size_t
> > +__fortify_function size_t
> >  __NTH (mbstowcs (wchar_t *__restrict __dst, const char *__restrict __src,
> >   size_t __len))
> >  {
> >    if (__builtin_constant_p (__dst == NULL) && __dst == NULL)
> > -    return __mbstowcs_chk_nulldst (__dst, __src, __len);
> > +    return __mbstowcs_nulldst (__dst, __src, __len);
> >    else
> >      return __glibc_fortify_n (mbstowcs, __len, sizeof (wchar_t),
> >         __glibc_objsize (__dst), __dst, __src, __len);
> > ```
> >
> > can you try this. I am totally unable to reproduce this but its obviously a bug.
>
> That works (modulo tab/space)
>
> Summary of test results:
>    5067 PASS
>      76 UNSUPPORTED
>      18 XFAIL
>       4 XPASS
>
> Thanks!
>
> > What build flags are you using? Whatever I have is insufficient.
>
> Nothing. Really just:
> ../glibc/configure --prefix=/usr && make -j8 && make check -j8

Ahh, I generally use `make xcheck`. Although I had no issue running
the tests individually.

:/

Will post a proper patch with inline fixes.
>
> This is a fairly standard Fedora 35 install.
> glibc 2.34.
> gcc 11.3.1
> binutils 2.37
>
> Cheers,
>
> Mark
>

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

* Re: [PATCH v2] stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265]
  2022-06-22 15:24 ` [PATCH v2] " Noah Goldstein
@ 2022-06-22 15:30   ` Siddhesh Poyarekar
  0 siblings, 0 replies; 11+ messages in thread
From: Siddhesh Poyarekar @ 2022-06-22 15:30 UTC (permalink / raw)
  To: Noah Goldstein, libc-alpha

On 22/06/2022 20:54, Noah Goldstein via Libc-alpha wrote:
> mbstows is defined if dst is NULL and is defined to special cased if
> dst is NULL so the fortify objsize check if incorrect in that case.
> 
> Tested on x86-64 linux.
> ---
>   stdlib/Makefile      |  3 +++
>   stdlib/bits/stdlib.h | 16 +++++++++++-----
>   stdlib/testmb.c      |  7 +++++++
>   3 files changed, 21 insertions(+), 5 deletions(-)

LGTM.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

> 
> diff --git a/stdlib/Makefile b/stdlib/Makefile
> index 60fc59c12c..6ef725ef74 100644
> --- a/stdlib/Makefile
> +++ b/stdlib/Makefile
> @@ -373,6 +373,9 @@ CFLAGS-tst-qsort.c += $(stack-align-test-flags)
>   CFLAGS-tst-makecontext.c += -funwind-tables
>   CFLAGS-tst-makecontext2.c += $(stack-align-test-flags)
>   
> +CFLAGS-testmb.c += -D_FORTIFY_SOURCE=2 -Wall -Werror
> +
> +
>   # Run a test on the header files we use.
>   tests-special += $(objpfx)isomac.out
>   
> diff --git a/stdlib/bits/stdlib.h b/stdlib/bits/stdlib.h
> index 277d099e22..d9c2d822a5 100644
> --- a/stdlib/bits/stdlib.h
> +++ b/stdlib/bits/stdlib.h
> @@ -96,6 +96,11 @@ extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
>   			      const char *__restrict __src,
>   			      size_t __len, size_t __dstlen) __THROW
>       __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
> +extern size_t __REDIRECT_NTH (__mbstowcs_chk_nulldst,
> +			      (wchar_t *__restrict __dst,
> +			       const char *__restrict __src,
> +			       size_t __len), mbstowcs_chk)
> +    __attr_access ((__read_only__, 2));
>   extern size_t __REDIRECT_NTH (__mbstowcs_alias,
>   			      (wchar_t *__restrict __dst,
>   			       const char *__restrict __src,
> @@ -108,16 +113,17 @@ extern size_t __REDIRECT_NTH (__mbstowcs_chk_warn,
>        __warnattr ("mbstowcs called with dst buffer smaller than len "
>   		 "* sizeof (wchar_t)");
>   
> -__fortify_function size_t
> +__always_inline __fortify_function size_t
>   __NTH (mbstowcs (wchar_t *__restrict __dst, const char *__restrict __src,
>   		 size_t __len))
>   {
> -  return __glibc_fortify_n (mbstowcs, __len, sizeof (wchar_t),
> -			    __glibc_objsize (__dst),
> -			    __dst, __src, __len);
> +  if (__builtin_constant_p (__dst == NULL) && __dst == NULL)
> +    return __mbstowcs_chk_nulldst (__dst, __src, __len);
> +  else
> +    return __glibc_fortify_n (mbstowcs, __len, sizeof (wchar_t),
> +			      __glibc_objsize (__dst), __dst, __src, __len);
>   }
>   
> -
>   extern size_t __wcstombs_chk (char *__restrict __dst,
>   			      const wchar_t *__restrict __src,
>   			      size_t __len, size_t __dstlen) __THROW
> diff --git a/stdlib/testmb.c b/stdlib/testmb.c
> index 45dae7db61..6ac4dfd21d 100644
> --- a/stdlib/testmb.c
> +++ b/stdlib/testmb.c
> @@ -16,6 +16,13 @@ main (int argc, char *argv[])
>         lose = 1;
>       }
>   
> +  i = mbstowcs (NULL, "bar", 4);
> +  if (!(i == 3 && w[1] == 'a'))
> +    {
> +      puts ("mbstowcs FAILED2!");
> +      lose = 1;
> +    }
> +
>     mbstowcs (w, "blah", 5);
>     i = wcstombs (c, w, 10);
>     if (i != 4)


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

* [PATCH v2] stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265]
  2022-06-21 16:18 [PATCH v1] " Noah Goldstein
@ 2022-06-22 15:24 ` Noah Goldstein
  2022-06-22 15:30   ` Siddhesh Poyarekar
  0 siblings, 1 reply; 11+ messages in thread
From: Noah Goldstein @ 2022-06-22 15:24 UTC (permalink / raw)
  To: libc-alpha

mbstows is defined if dst is NULL and is defined to special cased if
dst is NULL so the fortify objsize check if incorrect in that case.

Tested on x86-64 linux.
---
 stdlib/Makefile      |  3 +++
 stdlib/bits/stdlib.h | 16 +++++++++++-----
 stdlib/testmb.c      |  7 +++++++
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/stdlib/Makefile b/stdlib/Makefile
index 60fc59c12c..6ef725ef74 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -373,6 +373,9 @@ CFLAGS-tst-qsort.c += $(stack-align-test-flags)
 CFLAGS-tst-makecontext.c += -funwind-tables
 CFLAGS-tst-makecontext2.c += $(stack-align-test-flags)
 
+CFLAGS-testmb.c += -D_FORTIFY_SOURCE=2 -Wall -Werror
+
+
 # Run a test on the header files we use.
 tests-special += $(objpfx)isomac.out
 
diff --git a/stdlib/bits/stdlib.h b/stdlib/bits/stdlib.h
index 277d099e22..d9c2d822a5 100644
--- a/stdlib/bits/stdlib.h
+++ b/stdlib/bits/stdlib.h
@@ -96,6 +96,11 @@ extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
 			      const char *__restrict __src,
 			      size_t __len, size_t __dstlen) __THROW
     __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
+extern size_t __REDIRECT_NTH (__mbstowcs_chk_nulldst,
+			      (wchar_t *__restrict __dst,
+			       const char *__restrict __src,
+			       size_t __len), mbstowcs_chk)
+    __attr_access ((__read_only__, 2));
 extern size_t __REDIRECT_NTH (__mbstowcs_alias,
 			      (wchar_t *__restrict __dst,
 			       const char *__restrict __src,
@@ -108,16 +113,17 @@ extern size_t __REDIRECT_NTH (__mbstowcs_chk_warn,
      __warnattr ("mbstowcs called with dst buffer smaller than len "
 		 "* sizeof (wchar_t)");
 
-__fortify_function size_t
+__always_inline __fortify_function size_t
 __NTH (mbstowcs (wchar_t *__restrict __dst, const char *__restrict __src,
 		 size_t __len))
 {
-  return __glibc_fortify_n (mbstowcs, __len, sizeof (wchar_t),
-			    __glibc_objsize (__dst),
-			    __dst, __src, __len);
+  if (__builtin_constant_p (__dst == NULL) && __dst == NULL)
+    return __mbstowcs_chk_nulldst (__dst, __src, __len);
+  else
+    return __glibc_fortify_n (mbstowcs, __len, sizeof (wchar_t),
+			      __glibc_objsize (__dst), __dst, __src, __len);
 }
 
-
 extern size_t __wcstombs_chk (char *__restrict __dst,
 			      const wchar_t *__restrict __src,
 			      size_t __len, size_t __dstlen) __THROW
diff --git a/stdlib/testmb.c b/stdlib/testmb.c
index 45dae7db61..6ac4dfd21d 100644
--- a/stdlib/testmb.c
+++ b/stdlib/testmb.c
@@ -16,6 +16,13 @@ main (int argc, char *argv[])
       lose = 1;
     }
 
+  i = mbstowcs (NULL, "bar", 4);
+  if (!(i == 3 && w[1] == 'a'))
+    {
+      puts ("mbstowcs FAILED2!");
+      lose = 1;
+    }
+
   mbstowcs (w, "blah", 5);
   i = wcstombs (c, w, 10);
   if (i != 4)
-- 
2.34.1


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

end of thread, other threads:[~2022-06-22 23:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <7a0d8978-3774-49d6-a7d5-130c3268a5b6gotplt!org>
2022-06-22 20:56 ` [PATCH v2] stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265] Mark Wielaard
2022-06-22 21:38   ` Noah Goldstein
2022-06-22 22:06     ` Mark Wielaard
2022-06-22 22:34       ` Noah Goldstein
2022-06-22 22:45         ` Mark Wielaard
2022-06-22 23:02           ` Noah Goldstein
2022-06-22 22:38       ` Noah Goldstein
2022-06-22 23:16         ` Mark Wielaard
2022-06-22 23:30           ` Noah Goldstein
2022-06-21 16:18 [PATCH v1] " Noah Goldstein
2022-06-22 15:24 ` [PATCH v2] " Noah Goldstein
2022-06-22 15:30   ` Siddhesh Poyarekar

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