public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix stringop-overflow warning in tst-strlcat2.
@ 2024-01-16  8:44 Stefan Liebler
  2024-02-05 13:28 ` Stefan Liebler
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Stefan Liebler @ 2024-01-16  8:44 UTC (permalink / raw)
  To: libc-alpha; +Cc: Stefan Liebler

On s390x, I get warnings like this when do_one_test is inlined with SIZE_MAX:
In function ‘do_one_test’,
    inlined from ‘do_overflow_tests’ at tst-strlcat2.c:184:2:
tst-strlcat2.c:49:18: error: ‘strnlen’ specified bound [18446744073709550866, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
   49 | # define STRNLEN strnlen
      |                  ^
tst-strlcat2.c:89:23: note: in expansion of macro ‘STRNLEN’
   89 |   size_t dst_length = STRNLEN (dst, n);
      |                       ^~~~~~~

This patch just marks the do_one_test function as noinline as also done in test-strncat.c:
Fix stringop-overflow warning in test-strncat.
https://sourceware.org/git/?p=glibc.git;a=commit;h=51aeab9a363a0d000d0912aa3d6490463a26fba2
---
 string/tst-strlcat2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/string/tst-strlcat2.c b/string/tst-strlcat2.c
index 225520a46b..1ec26a2432 100644
--- a/string/tst-strlcat2.c
+++ b/string/tst-strlcat2.c
@@ -81,6 +81,7 @@ IMPL (STRLCAT, 1)
 typedef size_t (*proto_t) (CHAR *, const CHAR *, size_t);
 
 static void
+__attribute__((noinline))
 do_one_test (impl_t *impl, CHAR *dst, const CHAR *src,
 	     size_t n)
 {
-- 
2.43.0


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

* Re: [PATCH] Fix stringop-overflow warning in tst-strlcat2.
  2024-01-16  8:44 [PATCH] Fix stringop-overflow warning in tst-strlcat2 Stefan Liebler
@ 2024-02-05 13:28 ` Stefan Liebler
  2024-02-05 13:29 ` Stefan Liebler
  2024-02-05 13:53 ` Adhemerval Zanella Netto
  2 siblings, 0 replies; 5+ messages in thread
From: Stefan Liebler @ 2024-02-05 13:28 UTC (permalink / raw)
  To: GNU C Library

ping
On 16.01.24 09:44, Stefan Liebler wrote:
> On s390x, I get warnings like this when do_one_test is inlined with SIZE_MAX:
> In function ‘do_one_test’,
>     inlined from ‘do_overflow_tests’ at tst-strlcat2.c:184:2:
> tst-strlcat2.c:49:18: error: ‘strnlen’ specified bound [18446744073709550866, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
>    49 | # define STRNLEN strnlen
>       |                  ^
> tst-strlcat2.c:89:23: note: in expansion of macro ‘STRNLEN’
>    89 |   size_t dst_length = STRNLEN (dst, n);
>       |                       ^~~~~~~
> 
> This patch just marks the do_one_test function as noinline as also done in test-strncat.c:
> Fix stringop-overflow warning in test-strncat.
> https://sourceware.org/git/?p=glibc.git;a=commit;h=51aeab9a363a0d000d0912aa3d6490463a26fba2
> ---
>  string/tst-strlcat2.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/string/tst-strlcat2.c b/string/tst-strlcat2.c
> index 225520a46b..1ec26a2432 100644
> --- a/string/tst-strlcat2.c
> +++ b/string/tst-strlcat2.c
> @@ -81,6 +81,7 @@ IMPL (STRLCAT, 1)
>  typedef size_t (*proto_t) (CHAR *, const CHAR *, size_t);
>  
>  static void
> +__attribute__((noinline))
>  do_one_test (impl_t *impl, CHAR *dst, const CHAR *src,
>  	     size_t n)
>  {


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

* Re: [PATCH] Fix stringop-overflow warning in tst-strlcat2.
  2024-01-16  8:44 [PATCH] Fix stringop-overflow warning in tst-strlcat2 Stefan Liebler
  2024-02-05 13:28 ` Stefan Liebler
@ 2024-02-05 13:29 ` Stefan Liebler
  2024-02-05 13:53 ` Adhemerval Zanella Netto
  2 siblings, 0 replies; 5+ messages in thread
From: Stefan Liebler @ 2024-02-05 13:29 UTC (permalink / raw)
  To: Stefan Liebler, GNU C Library

ping
On 16.01.24 09:44, Stefan Liebler wrote:
> On s390x, I get warnings like this when do_one_test is inlined with SIZE_MAX:
> In function ‘do_one_test’,
>     inlined from ‘do_overflow_tests’ at tst-strlcat2.c:184:2:
> tst-strlcat2.c:49:18: error: ‘strnlen’ specified bound [18446744073709550866, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
>    49 | # define STRNLEN strnlen
>       |                  ^
> tst-strlcat2.c:89:23: note: in expansion of macro ‘STRNLEN’
>    89 |   size_t dst_length = STRNLEN (dst, n);
>       |                       ^~~~~~~
> 
> This patch just marks the do_one_test function as noinline as also done in test-strncat.c:
> Fix stringop-overflow warning in test-strncat.
> https://sourceware.org/git/?p=glibc.git;a=commit;h=51aeab9a363a0d000d0912aa3d6490463a26fba2
> ---
>  string/tst-strlcat2.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/string/tst-strlcat2.c b/string/tst-strlcat2.c
> index 225520a46b..1ec26a2432 100644
> --- a/string/tst-strlcat2.c
> +++ b/string/tst-strlcat2.c
> @@ -81,6 +81,7 @@ IMPL (STRLCAT, 1)
>  typedef size_t (*proto_t) (CHAR *, const CHAR *, size_t);
>  
>  static void
> +__attribute__((noinline))
>  do_one_test (impl_t *impl, CHAR *dst, const CHAR *src,
>  	     size_t n)
>  {


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

* Re: [PATCH] Fix stringop-overflow warning in tst-strlcat2.
  2024-01-16  8:44 [PATCH] Fix stringop-overflow warning in tst-strlcat2 Stefan Liebler
  2024-02-05 13:28 ` Stefan Liebler
  2024-02-05 13:29 ` Stefan Liebler
@ 2024-02-05 13:53 ` Adhemerval Zanella Netto
  2024-02-05 14:15   ` Stefan Liebler
  2 siblings, 1 reply; 5+ messages in thread
From: Adhemerval Zanella Netto @ 2024-02-05 13:53 UTC (permalink / raw)
  To: Stefan Liebler, libc-alpha



On 16/01/24 05:44, Stefan Liebler wrote:
> On s390x, I get warnings like this when do_one_test is inlined with SIZE_MAX:
> In function ‘do_one_test’,
>     inlined from ‘do_overflow_tests’ at tst-strlcat2.c:184:2:
> tst-strlcat2.c:49:18: error: ‘strnlen’ specified bound [18446744073709550866, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
>    49 | # define STRNLEN strnlen
>       |                  ^
> tst-strlcat2.c:89:23: note: in expansion of macro ‘STRNLEN’
>    89 |   size_t dst_length = STRNLEN (dst, n);
>       |                       ^~~~~~~
> 
> This patch just marks the do_one_test function as noinline as also done in test-strncat.c:
> Fix stringop-overflow warning in test-strncat.
> https://sourceware.org/git/?p=glibc.git;a=commit;h=51aeab9a363a0d000d0912aa3d6490463a26fba2

LGTM, although I am not seeing this failure with gcc 13.2.1 on x86_64
nor on s390x (building with -Os).

> ---
>  string/tst-strlcat2.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/string/tst-strlcat2.c b/string/tst-strlcat2.c
> index 225520a46b..1ec26a2432 100644
> --- a/string/tst-strlcat2.c
> +++ b/string/tst-strlcat2.c
> @@ -81,6 +81,7 @@ IMPL (STRLCAT, 1)
>  typedef size_t (*proto_t) (CHAR *, const CHAR *, size_t);
>  
>  static void
> +__attribute__((noinline))
>  do_one_test (impl_t *impl, CHAR *dst, const CHAR *src,
>  	     size_t n)
>  {

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

* Re: [PATCH] Fix stringop-overflow warning in tst-strlcat2.
  2024-02-05 13:53 ` Adhemerval Zanella Netto
@ 2024-02-05 14:15   ` Stefan Liebler
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Liebler @ 2024-02-05 14:15 UTC (permalink / raw)
  To: Adhemerval Zanella Netto, libc-alpha

On 05.02.24 14:53, Adhemerval Zanella Netto wrote:
> 
> 
> On 16/01/24 05:44, Stefan Liebler wrote:
>> On s390x, I get warnings like this when do_one_test is inlined with SIZE_MAX:
>> In function ‘do_one_test’,
>>     inlined from ‘do_overflow_tests’ at tst-strlcat2.c:184:2:
>> tst-strlcat2.c:49:18: error: ‘strnlen’ specified bound [18446744073709550866, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
>>    49 | # define STRNLEN strnlen
>>       |                  ^
>> tst-strlcat2.c:89:23: note: in expansion of macro ‘STRNLEN’
>>    89 |   size_t dst_length = STRNLEN (dst, n);
>>       |                       ^~~~~~~
>>
>> This patch just marks the do_one_test function as noinline as also done in test-strncat.c:
>> Fix stringop-overflow warning in test-strncat.
>> https://sourceware.org/git/?p=glibc.git;a=commit;h=51aeab9a363a0d000d0912aa3d6490463a26fba2
> 
> LGTM, although I am not seeing this failure with gcc 13.2.1 on x86_64
> nor on s390x (building with -Os).
> 

Thanks and committed.
Yes, you are right. The recent gcc's on s390x does not inline so much as
with older versions. If I remember correctly, starting with gcc 10,
inlining was reduced (for s390x).

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

end of thread, other threads:[~2024-02-05 14:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16  8:44 [PATCH] Fix stringop-overflow warning in tst-strlcat2 Stefan Liebler
2024-02-05 13:28 ` Stefan Liebler
2024-02-05 13:29 ` Stefan Liebler
2024-02-05 13:53 ` Adhemerval Zanella Netto
2024-02-05 14:15   ` Stefan Liebler

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