Dear contributor,
Our automatic CI has detected problems related to your patch(es). Please find some details below.
In master-aarch64, after: | commit glibc-2.42.9000-537-gcd748a63ab1 | Author: Joseph Myers josmyers@redhat.com | Date: Thu Nov 20 19:30:27 2025 +0000 | | Implement C23 const-preserving standard library macros | | C23 makes various standard library functions, that return a pointer | into an input array, into macros that return a pointer to const when | the relevant argument passed to the macro is a pointer to const. (The | ... 35 lines of the commit log omitted.
Produces 5 regressions: | | regressions.sum: | Running gcc:gcc.dg/analyzer/analyzer.exp ... | FAIL: gcc.dg/analyzer/strchr-1.c (test for warnings, line 32) | FAIL: gcc.dg/analyzer/strchr-1.c (test for warnings, line 39) | FAIL: gcc.dg/analyzer/strchr-1.c (test for excess errors) | FAIL: gcc.dg/analyzer/strchr-1.c event at line 33 (test for warnings, line 32) | ... and 1 more
Used configuration : *CI config* tcwg_gnu_native_check_gcc master-aarch64 *configure and test flags:* none, autodetected on aarch64-unknown-linux-gnu
We track this bug report under https://linaro.atlassian.net/browse/GNU-1756. Please let us know if you have a fix.
If you have any questions regarding this report, please ask on linaro-toolchain@lists.linaro.org mailing list.
-----------------8<--------------------------8<--------------------------8<--------------------------
The information below contains the details of the failures, and the ways to reproduce a debug environment:
You can find the failure logs in *.log.1.xz files in * https://ci.linaro.org/job/tcwg_gnu_native_check_gcc--master-aarch64-build/22... The full lists of regressions and improvements as well as configure and make commands are in * https://ci.linaro.org/job/tcwg_gnu_native_check_gcc--master-aarch64-build/22... The list of [ignored] baseline and flaky failures are in * https://ci.linaro.org/job/tcwg_gnu_native_check_gcc--master-aarch64-build/22...
Current build : https://ci.linaro.org/job/tcwg_gnu_native_check_gcc--master-aarch64-build/22... Reference build : https://ci.linaro.org/job/tcwg_gnu_native_check_gcc--master-aarch64-build/22...
Instruction to reproduce the build : https://gitlab.com/LinaroLtd/tcwg/ci/interesting-commits/-/raw/master/glibc/...
Full commit : https://sourceware.org/git/?p=glibc.git%3Ba=commitdiff%3Bh=cd748a63ab1a7ae84...
On Fri, 21 Nov 2025, ci_notify@linaro.org wrote:
Dear contributor,
Our automatic CI has detected problems related to your patch(es). Please find some details below.
In master-aarch64, after: | commit glibc-2.42.9000-537-gcd748a63ab1 | Author: Joseph Myers josmyers@redhat.com | Date: Thu Nov 20 19:30:27 2025 +0000 | | Implement C23 const-preserving standard library macros | | C23 makes various standard library functions, that return a pointer | into an input array, into macros that return a pointer to const when | the relevant argument passed to the macro is a pointer to const. (The | ... 35 lines of the commit log omitted.
Produces 5 regressions: | | regressions.sum: | Running gcc:gcc.dg/analyzer/analyzer.exp ... | FAIL: gcc.dg/analyzer/strchr-1.c (test for warnings, line 32) | FAIL: gcc.dg/analyzer/strchr-1.c (test for warnings, line 39) | FAIL: gcc.dg/analyzer/strchr-1.c (test for excess errors) | FAIL: gcc.dg/analyzer/strchr-1.c event at line 33 (test for warnings, line 32)
I'm not sure why this test is using the strchr declaration from <string.h> as well as __builtin_strchr, but depending on the goals of doing so, the options to fix this are either making the test const-correct so it works with the C23 macro, or suppressing macro expansion.
On Fri, 2025-11-21 at 20:15 +0000, Joseph Myers wrote:
On Fri, 21 Nov 2025, ci_notify@linaro.org wrote:
Dear contributor,
Our automatic CI has detected problems related to your patch(es). Please find some details below.
In master-aarch64, after: | commit glibc-2.42.9000-537-gcd748a63ab1 | Author: Joseph Myers josmyers@redhat.com | Date: Thu Nov 20 19:30:27 2025 +0000 | | Implement C23 const-preserving standard library macros | | C23 makes various standard library functions, that return a pointer | into an input array, into macros that return a pointer to const when | the relevant argument passed to the macro is a pointer to const. (The | ... 35 lines of the commit log omitted.
Produces 5 regressions: | | regressions.sum: | Running gcc:gcc.dg/analyzer/analyzer.exp ... | FAIL: gcc.dg/analyzer/strchr-1.c (test for warnings, line 32) | FAIL: gcc.dg/analyzer/strchr-1.c (test for warnings, line 39) | FAIL: gcc.dg/analyzer/strchr-1.c (test for excess errors) | FAIL: gcc.dg/analyzer/strchr-1.c event at line 33 (test for warnings, line 32)
I'm not sure why this test is using the strchr declaration from <string.h> as well as __builtin_strchr, but depending on the goals of doing so, the options to fix this are either making the test const-correct so it works with the C23 macro, or suppressing macro expansion.
Do you have a URL for the failure? I wonder if there's a way for me to test this from the GCC side.
The intent of the test is to verify that the analyzer "knows" about the behavior of strchr, so the best fix here probably is to simply use __builtin_strchr throughout, and drop the include of <string.h>.
Dave
David Malcolm via linaro-toolchain linaro-toolchain@lists.linaro.org writes:
On Fri, 2025-11-21 at 20:15 +0000, Joseph Myers wrote:
On Fri, 21 Nov 2025, ci_notify@linaro.org wrote:
Dear contributor,
Our automatic CI has detected problems related to your patch(es). Please find some details below.
In master-aarch64, after: | commit glibc-2.42.9000-537-gcd748a63ab1 | Author: Joseph Myers josmyers@redhat.com | Date: Thu Nov 20 19:30:27 2025 +0000 | | Implement C23 const-preserving standard library macros | | C23 makes various standard library functions, that return a pointer | into an input array, into macros that return a pointer to const when | the relevant argument passed to the macro is a pointer to const. (The | ... 35 lines of the commit log omitted.
Produces 5 regressions: | | regressions.sum: | Running gcc:gcc.dg/analyzer/analyzer.exp ... | FAIL: gcc.dg/analyzer/strchr-1.c (test for warnings, line 32) | FAIL: gcc.dg/analyzer/strchr-1.c (test for warnings, line 39) | FAIL: gcc.dg/analyzer/strchr-1.c (test for excess errors) | FAIL: gcc.dg/analyzer/strchr-1.c event at line 33 (test for warnings, line 32)
I'm not sure why this test is using the strchr declaration from <string.h> as well as __builtin_strchr, but depending on the goals of doing so, the options to fix this are either making the test const-correct so it works with the C23 macro, or suppressing macro expansion.
Do you have a URL for the failure?
You can find the log for the failure above here:
https://ci.linaro.org/job/tcwg_gnu_native_check_gcc--master-aarch64-build/22...
I wonder if there's a way for me to test this from the GCC side.
I haven't tried yet, but I believe you can reproduce by building the gcc testcase against glibc from trunk as described here:
https://sourceware.org/glibc/wiki/Testing/Builds#Compile_against_glibc_in_an...
The intent of the test is to verify that the analyzer "knows" about the behavior of strchr, so the best fix here probably is to simply use __builtin_strchr throughout, and drop the include of <string.h>.
Simplify this test case in the hope of avoiding an error seen with glibc-2.42.9000-537-gcd748a63ab1 in CI with "Implement C23 const-preserving standard library macros".
Successfully regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r16-5590-g06f094958161f8.
gcc/testsuite/ChangeLog: * gcc.dg/analyzer/strchr-1.c: Drop include of <string.h>, and use __builtin_strchr throughout rather than strchr to avoid const correctness issues when the header implements strchr with a C23 const-preserving macro. Drop "const" from two vars.
Signed-off-by: David Malcolm dmalcolm@redhat.com --- gcc/testsuite/gcc.dg/analyzer/strchr-1.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/analyzer/strchr-1.c b/gcc/testsuite/gcc.dg/analyzer/strchr-1.c index 181f1829724f8..5cc5fe55734fa 100644 --- a/gcc/testsuite/gcc.dg/analyzer/strchr-1.c +++ b/gcc/testsuite/gcc.dg/analyzer/strchr-1.c @@ -1,4 +1,3 @@ -#include <string.h> #include "analyzer-decls.h"
const char* test_literal (int x) @@ -14,28 +13,28 @@ const char* test_literal (int x) return p; }
-void test_2 (const char *s, int c) +void test_2 (char *s, int c) { char *p = __builtin_strchr (s, c); /* { dg-message "when '__builtin_strchr' returns NULL" } */ *p = 'A'; /* { dg-warning "dereference of NULL 'p'" "null deref" } */ }
-void test_3 (const char *s, int c) +void test_3 (char *s, int c) { - char *p = strchr (s, c); /* { dg-message "when 'strchr' returns NULL" } */ + char *p = __builtin_strchr (s, c); /* { dg-message "when '__builtin_strchr' returns NULL" } */ *p = 'A'; /* { dg-warning "dereference of NULL 'p'" "null deref" } */ }
void test_unterminated (int c) { char buf[3] = "abc"; - strchr (buf, c); /* { dg-warning "stack-based buffer over-read" } */ - /* { dg-message "while looking for null terminator for argument 1 \('&buf'\) of 'strchr'..." "event" { target *-*-* } .-1 } */ + __builtin_strchr (buf, c); /* { dg-warning "stack-based buffer over-read" } */ + /* { dg-message "while looking for null terminator for argument 1 \('&buf'\) of '__builtin_strchr'..." "event" { target *-*-* } .-1 } */ }
void test_uninitialized (int c) { char buf[16]; - strchr (buf, c); /* { dg-warning "use of uninitialized value 'buf\[0\]'" } */ - /* { dg-message "while looking for null terminator for argument 1 \('&buf'\) of 'strchr'..." "event" { target *-*-* } .-1 } */ + __builtin_strchr (buf, c); /* { dg-warning "use of uninitialized value 'buf\[0\]'" } */ + /* { dg-message "while looking for null terminator for argument 1 \('&buf'\) of '__builtin_strchr'..." "event" { target *-*-* } .-1 } */ }
linaro-toolchain@lists.linaro.org