Skip to content

Conversation

jhuber6
Copy link
Contributor

@jhuber6 jhuber6 commented Aug 20, 2025

Summary:
This patch changes the linux build to use the wide reads on the memory
operations by default. These memory functions will now potentially read
outside of the bounds explicitly allowed by the current function. While
technically undefined behavior in the standard, plenty of C library
implementations do this. it will not cause a segmentation fault on linux
as long as you do not cross a page boundary, and because we are only
reading memory it should not have atomic effects.

@llvmbot
Copy link
Member

llvmbot commented Aug 20, 2025

@llvm/pr-subscribers-libc

Author: Joseph Huber (jhuber6)

Changes

Summary:
This patch changes the linux build to use the wide reads on the memory
operations by default. These memory functions will now potentially read
outside of the bounds explicitly allowed by the current function. While
technically undefined behavior in the standard, plenty of C library
implementations do this. it will not cause a segmentation fault on linux
as long as you do not cross a page boundary, and because we are only
reading memory it should not have atomic effects.


Full diff: https://github.com/llvm/llvm-project/pull/154602.diff

1 Files Affected:

  • (added) libc/config/linux/config.json (+7)
diff --git a/libc/config/linux/config.json b/libc/config/linux/config.json
new file mode 100644
index 0000000000000..30e8b2cdadabe
--- /dev/null
+++ b/libc/config/linux/config.json
@@ -0,0 +1,7 @@
+{
+  "string": {
+    "LIBC_CONF_STRING_UNSAFE_WIDE_READ": {
+      "value": true
+    }
+  }
+}

Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jhuber6
Copy link
Contributor Author

jhuber6 commented Aug 20, 2025

Seems the AArch builder has some warnings that were never cleaned up. I'll try to fix those in this PR.

@jhuber6 jhuber6 force-pushed the wide branch 3 times, most recently from 8d8cc11 to 2208ffe Compare August 20, 2025 21:24
Copy link

github-actions bot commented Aug 20, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@jhuber6 jhuber6 force-pushed the wide branch 2 times, most recently from 3fda3ee to 03d371e Compare August 20, 2025 21:31
Summary:
This patch changes the linux build to use the wide reads on the memory
operations by default. These memory functions will now potentially read
outside of the bounds explicitly allowed by the current function. While
technically undefined behavior in the standard, plenty of C library
implementations do this. it will not cause a segmentation fault on linux
as long as you do not cross a page boundary, and because we are only
*reading* memory it should not have atomic effects.
@jhuber6 jhuber6 merged commit c80d148 into llvm:main Aug 20, 2025
19 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 20, 2025

LLVM Buildbot has detected a new failure on builder libc-arm32-qemu-debian-dbg running on libc-arm32-qemu-debian while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/215/builds/3829

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[241/282] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.bf16div.dir/bf16div.cpp.o
[242/282] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.bf16addl.dir/bf16addl.cpp.o
[243/282] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.bf16addf.dir/bf16addf.cpp.o
[244/282] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.bf16divf.dir/bf16divf.cpp.o
[245/282] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.cbrt.dir/cbrt.cpp.o
[246/282] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.bf16divl.dir/bf16divl.cpp.o
[247/282] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.atof.dir/atof.cpp.o
[248/282] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.strtof.dir/strtof.cpp.o
[249/282] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.div.dir/div.cpp.o
[250/282] Building CXX object libc/src/string/CMakeFiles/libc.src.string.memchr.dir/memchr.cpp.o
FAILED: libc/src/string/CMakeFiles/libc.src.string.memchr.dir/memchr.cpp.o 
/usr/bin/clang++ --target=arm-linux-gnueabihf --sysroot=/opt/sysroot-deb-armhf-stable -DLIBC_NAMESPACE=__llvm_libc_21_0_0_git -D_DEBUG -I/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc -isystem /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/build/libc/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g --target=arm-linux-gnueabihf -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -DLIBC_THREAD_MODE=LIBC_THREAD_MODE_PLATFORM -fpie -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -DLIBC_COPT_STRING_UNSAFE_WIDE_READ -std=gnu++17 -MD -MT libc/src/string/CMakeFiles/libc.src.string.memchr.dir/memchr.cpp.o -MF libc/src/string/CMakeFiles/libc.src.string.memchr.dir/memchr.cpp.o.d -o libc/src/string/CMakeFiles/libc.src.string.memchr.dir/memchr.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/memchr.cpp
In file included from /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/memchr.cpp:12:
/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/string_utils.h:31:48: error: expected namespace name
namespace string_length_impl = LIBC_NAMESPACE::wide_read;
                               ~~~~~~~~~~~~~~~~^
/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/string_utils.h:110:12: error: use of undeclared identifier 'string_length_impl'
    return string_length_impl::string_length(src);
           ^
2 errors generated.
[251/282] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.ldiv.dir/ldiv.cpp.o
[252/282] Building CXX object libc/src/string/CMakeFiles/libc.src.string.strcat.dir/strcat.cpp.o
FAILED: libc/src/string/CMakeFiles/libc.src.string.strcat.dir/strcat.cpp.o 
/usr/bin/clang++ --target=arm-linux-gnueabihf --sysroot=/opt/sysroot-deb-armhf-stable -DLIBC_NAMESPACE=__llvm_libc_21_0_0_git -D_DEBUG -I/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc -isystem /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/build/libc/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g --target=arm-linux-gnueabihf -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -DLIBC_THREAD_MODE=LIBC_THREAD_MODE_PLATFORM -fpie -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -DLIBC_COPT_STRING_UNSAFE_WIDE_READ -std=gnu++17 -MD -MT libc/src/string/CMakeFiles/libc.src.string.strcat.dir/strcat.cpp.o -MF libc/src/string/CMakeFiles/libc.src.string.strcat.dir/strcat.cpp.o.d -o libc/src/string/CMakeFiles/libc.src.string.strcat.dir/strcat.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/strcat.cpp
In file included from /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/strcat.cpp:12:
/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/string_utils.h:31:48: error: expected namespace name
namespace string_length_impl = LIBC_NAMESPACE::wide_read;
                               ~~~~~~~~~~~~~~~~^
/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/string_utils.h:110:12: error: use of undeclared identifier 'string_length_impl'
    return string_length_impl::string_length(src);
           ^
2 errors generated.
[253/282] Building CXX object libc/src/string/CMakeFiles/libc.src.string.strchrnul.dir/strchrnul.cpp.o
FAILED: libc/src/string/CMakeFiles/libc.src.string.strchrnul.dir/strchrnul.cpp.o 
/usr/bin/clang++ --target=arm-linux-gnueabihf --sysroot=/opt/sysroot-deb-armhf-stable -DLIBC_NAMESPACE=__llvm_libc_21_0_0_git -D_DEBUG -I/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc -isystem /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/build/libc/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g --target=arm-linux-gnueabihf -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -DLIBC_THREAD_MODE=LIBC_THREAD_MODE_PLATFORM -fpie -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -DLIBC_COPT_STRING_UNSAFE_WIDE_READ -std=gnu++17 -MD -MT libc/src/string/CMakeFiles/libc.src.string.strchrnul.dir/strchrnul.cpp.o -MF libc/src/string/CMakeFiles/libc.src.string.strchrnul.dir/strchrnul.cpp.o.d -o libc/src/string/CMakeFiles/libc.src.string.strchrnul.dir/strchrnul.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/strchrnul.cpp
In file included from /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/strchrnul.cpp:11:
/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/string_utils.h:31:48: error: expected namespace name
namespace string_length_impl = LIBC_NAMESPACE::wide_read;
                               ~~~~~~~~~~~~~~~~^
/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/string_utils.h:110:12: error: use of undeclared identifier 'string_length_impl'
    return string_length_impl::string_length(src);
           ^
2 errors generated.
[254/282] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.lldiv.dir/lldiv.cpp.o
[255/282] Building CXX object libc/src/string/CMakeFiles/libc.src.string.stpcpy.dir/stpcpy.cpp.o
FAILED: libc/src/string/CMakeFiles/libc.src.string.stpcpy.dir/stpcpy.cpp.o 
/usr/bin/clang++ --target=arm-linux-gnueabihf --sysroot=/opt/sysroot-deb-armhf-stable -DLIBC_NAMESPACE=__llvm_libc_21_0_0_git -D_DEBUG -I/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc -isystem /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/build/libc/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g --target=arm-linux-gnueabihf -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -DLIBC_THREAD_MODE=LIBC_THREAD_MODE_PLATFORM -fpie -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -DLIBC_COPT_STRING_UNSAFE_WIDE_READ -std=gnu++17 -MD -MT libc/src/string/CMakeFiles/libc.src.string.stpcpy.dir/stpcpy.cpp.o -MF libc/src/string/CMakeFiles/libc.src.string.stpcpy.dir/stpcpy.cpp.o.d -o libc/src/string/CMakeFiles/libc.src.string.stpcpy.dir/stpcpy.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/stpcpy.cpp
In file included from /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/stpcpy.cpp:11:
/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/string_utils.h:31:48: error: expected namespace name
Step 6 (build libc) failure: build libc (failure)
...
[241/282] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.bf16div.dir/bf16div.cpp.o
[242/282] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.bf16addl.dir/bf16addl.cpp.o
[243/282] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.bf16addf.dir/bf16addf.cpp.o
[244/282] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.bf16divf.dir/bf16divf.cpp.o
[245/282] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.cbrt.dir/cbrt.cpp.o
[246/282] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.bf16divl.dir/bf16divl.cpp.o
[247/282] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.atof.dir/atof.cpp.o
[248/282] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.strtof.dir/strtof.cpp.o
[249/282] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.div.dir/div.cpp.o
[250/282] Building CXX object libc/src/string/CMakeFiles/libc.src.string.memchr.dir/memchr.cpp.o
FAILED: libc/src/string/CMakeFiles/libc.src.string.memchr.dir/memchr.cpp.o 
/usr/bin/clang++ --target=arm-linux-gnueabihf --sysroot=/opt/sysroot-deb-armhf-stable -DLIBC_NAMESPACE=__llvm_libc_21_0_0_git -D_DEBUG -I/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc -isystem /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/build/libc/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g --target=arm-linux-gnueabihf -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -DLIBC_THREAD_MODE=LIBC_THREAD_MODE_PLATFORM -fpie -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -DLIBC_COPT_STRING_UNSAFE_WIDE_READ -std=gnu++17 -MD -MT libc/src/string/CMakeFiles/libc.src.string.memchr.dir/memchr.cpp.o -MF libc/src/string/CMakeFiles/libc.src.string.memchr.dir/memchr.cpp.o.d -o libc/src/string/CMakeFiles/libc.src.string.memchr.dir/memchr.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/memchr.cpp
In file included from /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/memchr.cpp:12:
/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/string_utils.h:31:48: error: expected namespace name
namespace string_length_impl = LIBC_NAMESPACE::wide_read;
                               ~~~~~~~~~~~~~~~~^
/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/string_utils.h:110:12: error: use of undeclared identifier 'string_length_impl'
    return string_length_impl::string_length(src);
           ^
2 errors generated.
[251/282] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.ldiv.dir/ldiv.cpp.o
[252/282] Building CXX object libc/src/string/CMakeFiles/libc.src.string.strcat.dir/strcat.cpp.o
FAILED: libc/src/string/CMakeFiles/libc.src.string.strcat.dir/strcat.cpp.o 
/usr/bin/clang++ --target=arm-linux-gnueabihf --sysroot=/opt/sysroot-deb-armhf-stable -DLIBC_NAMESPACE=__llvm_libc_21_0_0_git -D_DEBUG -I/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc -isystem /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/build/libc/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g --target=arm-linux-gnueabihf -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -DLIBC_THREAD_MODE=LIBC_THREAD_MODE_PLATFORM -fpie -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -DLIBC_COPT_STRING_UNSAFE_WIDE_READ -std=gnu++17 -MD -MT libc/src/string/CMakeFiles/libc.src.string.strcat.dir/strcat.cpp.o -MF libc/src/string/CMakeFiles/libc.src.string.strcat.dir/strcat.cpp.o.d -o libc/src/string/CMakeFiles/libc.src.string.strcat.dir/strcat.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/strcat.cpp
In file included from /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/strcat.cpp:12:
/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/string_utils.h:31:48: error: expected namespace name
namespace string_length_impl = LIBC_NAMESPACE::wide_read;
                               ~~~~~~~~~~~~~~~~^
/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/string_utils.h:110:12: error: use of undeclared identifier 'string_length_impl'
    return string_length_impl::string_length(src);
           ^
2 errors generated.
[253/282] Building CXX object libc/src/string/CMakeFiles/libc.src.string.strchrnul.dir/strchrnul.cpp.o
FAILED: libc/src/string/CMakeFiles/libc.src.string.strchrnul.dir/strchrnul.cpp.o 
/usr/bin/clang++ --target=arm-linux-gnueabihf --sysroot=/opt/sysroot-deb-armhf-stable -DLIBC_NAMESPACE=__llvm_libc_21_0_0_git -D_DEBUG -I/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc -isystem /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/build/libc/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g --target=arm-linux-gnueabihf -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -DLIBC_THREAD_MODE=LIBC_THREAD_MODE_PLATFORM -fpie -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -DLIBC_COPT_STRING_UNSAFE_WIDE_READ -std=gnu++17 -MD -MT libc/src/string/CMakeFiles/libc.src.string.strchrnul.dir/strchrnul.cpp.o -MF libc/src/string/CMakeFiles/libc.src.string.strchrnul.dir/strchrnul.cpp.o.d -o libc/src/string/CMakeFiles/libc.src.string.strchrnul.dir/strchrnul.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/strchrnul.cpp
In file included from /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/strchrnul.cpp:11:
/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/string_utils.h:31:48: error: expected namespace name
namespace string_length_impl = LIBC_NAMESPACE::wide_read;
                               ~~~~~~~~~~~~~~~~^
/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/string_utils.h:110:12: error: use of undeclared identifier 'string_length_impl'
    return string_length_impl::string_length(src);
           ^
2 errors generated.
[254/282] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.lldiv.dir/lldiv.cpp.o
[255/282] Building CXX object libc/src/string/CMakeFiles/libc.src.string.stpcpy.dir/stpcpy.cpp.o
FAILED: libc/src/string/CMakeFiles/libc.src.string.stpcpy.dir/stpcpy.cpp.o 
/usr/bin/clang++ --target=arm-linux-gnueabihf --sysroot=/opt/sysroot-deb-armhf-stable -DLIBC_NAMESPACE=__llvm_libc_21_0_0_git -D_DEBUG -I/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc -isystem /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/build/libc/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g --target=arm-linux-gnueabihf -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -DLIBC_THREAD_MODE=LIBC_THREAD_MODE_PLATFORM -fpie -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -DLIBC_COPT_STRING_UNSAFE_WIDE_READ -std=gnu++17 -MD -MT libc/src/string/CMakeFiles/libc.src.string.stpcpy.dir/stpcpy.cpp.o -MF libc/src/string/CMakeFiles/libc.src.string.stpcpy.dir/stpcpy.cpp.o.d -o libc/src/string/CMakeFiles/libc.src.string.stpcpy.dir/stpcpy.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/stpcpy.cpp
In file included from /home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/stpcpy.cpp:11:
/home/llvm-libc-buildbot/buildbot-worker/libc-arm32-qemu-debian/libc-arm32-qemu-debian-dbg/llvm-project/libc/src/string/string_utils.h:31:48: error: expected namespace name

@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 20, 2025

LLVM Buildbot has detected a new failure on builder libc-x86_64-debian-dbg-asan running on libc-x86_64-debian while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/147/builds/27552

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[1084/1259] Running unit test libc.test.src.strings.strcasecmp_test.__unit__
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcStrCaseCmpTest.EmptyStringsShouldReturnZero
[       OK ] LlvmLibcStrCaseCmpTest.EmptyStringsShouldReturnZero (13 us)
[ RUN      ] LlvmLibcStrCaseCmpTest.EmptyStringShouldNotEqualNonEmptyString
[       OK ] LlvmLibcStrCaseCmpTest.EmptyStringShouldNotEqualNonEmptyString (3 us)
[ RUN      ] LlvmLibcStrCaseCmpTest.Case
[       OK ] LlvmLibcStrCaseCmpTest.Case (3 us)
Ran 3 tests.  PASS: 3  FAIL: 0
[1085/1259] Running unit test libc.test.src.string.strdup_test.__unit__
FAILED: libc/test/src/string/CMakeFiles/libc.test.src.string.strdup_test.__unit__ /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/libc/test/src/string/CMakeFiles/libc.test.src.string.strdup_test.__unit__ 
cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/libc/test/src/string && /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/libc/test/src/string/libc.test.src.string.strdup_test.__unit__.__build__
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcStrDupTest.EmptyString
=================================================================
==689718==ERROR: AddressSanitizer: global-buffer-overflow on address 0x55c209b3e680 at pc 0x55c209ae1ebb bp 0x7ffde306eed0 sp 0x7ffde306eec8
READ of size 16 at 0x55c209b3e680 thread T0
    #0 0x55c209ae1eba in unsigned int __llvm_libc_20_0_0_git::string_length_internal::compare_and_mask<long long vector[2], unsigned int>(long long vector[2] const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/string/memory_utils/x86_64/inline_strlen.h:47:15
    #1 0x55c209ae1dd4 in unsigned long __llvm_libc_20_0_0_git::string_length_internal::string_length_vector<long long vector[2], unsigned int, &(unsigned int __llvm_libc_20_0_0_git::string_length_internal::compare_and_mask<long long vector[2], unsigned int>(long long vector[2] const*))>(char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/string/memory_utils/x86_64/inline_strlen.h:30:14
    #2 0x55c209ae2544 in __llvm_libc_20_0_0_git::string_length_internal::sse2::string_length(char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/string/memory_utils/x86_64/inline_strlen.h:55:10
    #3 0x55c209ae22c4 in unsigned long __llvm_libc_20_0_0_git::internal::string_length<char>(char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/string/string_utils.h:110:12
    #4 0x55c209ae204c in __llvm_libc_20_0_0_git::cpp::optional<char*> __llvm_libc_20_0_0_git::internal::strdup<char>(char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/string/allocating_string_utils.h:26:16
    #5 0x55c209ae1c05 in __llvm_libc_20_0_0_git::strdup(char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/string/strdup.cpp:21:14
    #6 0x55c209adf790 in LlvmLibcStrDupTest_EmptyString::Run() /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/src/string/strdup_test.cpp:18:18
    #7 0x55c209ae9d27 in __llvm_libc_20_0_0_git::testing::Test::runTests(__llvm_libc_20_0_0_git::testing::TestOptions const&) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/UnitTest/LibcTest.cpp:165:8
    #8 0x55c209b27438 in main /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/UnitTest/LibcTestMain.cpp:59:10
    #9 0x7fbb29e46249  (/lib/x86_64-linux-gnu/libc.so.6+0x27249) (BuildId: 79005c16293efa45b441fed45f4f29b138557e9e)

0x55c209b3e680 is located 32 bytes to the left of global variable '<string literal>' defined in '/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/src/string/strdup_test.cpp:19:3' (0x55c209b3e6a0) of size 2
  '<string literal>' is ascii string '0'
0x55c209b3e681 is located 0 bytes to the right of global variable '<string literal>' defined in '/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/src/string/strdup_test.cpp:16:23' (0x55c209b3e680) of size 1
  '<string literal>' is ascii string ''
SUMMARY: AddressSanitizer: global-buffer-overflow /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/string/memory_utils/x86_64/inline_strlen.h:47:15 in unsigned int __llvm_libc_20_0_0_git::string_length_internal::compare_and_mask<long long vector[2], unsigned int>(long long vector[2] const*)
Shadow bytes around the buggy address:
  0x0ab8c135fc80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab8c135fc90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab8c135fca0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab8c135fcb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab8c135fcc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0ab8c135fcd0:[01]f9 f9 f9 02 f9 f9 f9 00 00 00 05 f9 f9 f9 f9
  0x0ab8c135fce0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab8c135fcf0: 00 02 f9 f9 f9 f9 f9 f9 07 f9 f9 f9 00 00 00 05
  0x0ab8c135fd00: f9 f9 f9 f9 06 f9 f9 f9 00 00 00 00 01 f9 f9 f9
  0x0ab8c135fd10: f9 f9 f9 f9 04 f9 f9 f9 00 00 00 00 01 f9 f9 f9
  0x0ab8c135fd20: f9 f9 f9 f9 00 00 00 07 f9 f9 f9 f9 00 00 00 05
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
Step 7 (libc-unit-tests) failure: libc-unit-tests (failure)
...
[1084/1259] Running unit test libc.test.src.strings.strcasecmp_test.__unit__
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcStrCaseCmpTest.EmptyStringsShouldReturnZero
[       OK ] LlvmLibcStrCaseCmpTest.EmptyStringsShouldReturnZero (13 us)
[ RUN      ] LlvmLibcStrCaseCmpTest.EmptyStringShouldNotEqualNonEmptyString
[       OK ] LlvmLibcStrCaseCmpTest.EmptyStringShouldNotEqualNonEmptyString (3 us)
[ RUN      ] LlvmLibcStrCaseCmpTest.Case
[       OK ] LlvmLibcStrCaseCmpTest.Case (3 us)
Ran 3 tests.  PASS: 3  FAIL: 0
[1085/1259] Running unit test libc.test.src.string.strdup_test.__unit__
FAILED: libc/test/src/string/CMakeFiles/libc.test.src.string.strdup_test.__unit__ /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/libc/test/src/string/CMakeFiles/libc.test.src.string.strdup_test.__unit__ 
cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/libc/test/src/string && /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/libc/test/src/string/libc.test.src.string.strdup_test.__unit__.__build__
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcStrDupTest.EmptyString
=================================================================
==689718==ERROR: AddressSanitizer: global-buffer-overflow on address 0x55c209b3e680 at pc 0x55c209ae1ebb bp 0x7ffde306eed0 sp 0x7ffde306eec8
READ of size 16 at 0x55c209b3e680 thread T0
    #0 0x55c209ae1eba in unsigned int __llvm_libc_20_0_0_git::string_length_internal::compare_and_mask<long long vector[2], unsigned int>(long long vector[2] const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/string/memory_utils/x86_64/inline_strlen.h:47:15
    #1 0x55c209ae1dd4 in unsigned long __llvm_libc_20_0_0_git::string_length_internal::string_length_vector<long long vector[2], unsigned int, &(unsigned int __llvm_libc_20_0_0_git::string_length_internal::compare_and_mask<long long vector[2], unsigned int>(long long vector[2] const*))>(char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/string/memory_utils/x86_64/inline_strlen.h:30:14
    #2 0x55c209ae2544 in __llvm_libc_20_0_0_git::string_length_internal::sse2::string_length(char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/string/memory_utils/x86_64/inline_strlen.h:55:10
    #3 0x55c209ae22c4 in unsigned long __llvm_libc_20_0_0_git::internal::string_length<char>(char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/string/string_utils.h:110:12
    #4 0x55c209ae204c in __llvm_libc_20_0_0_git::cpp::optional<char*> __llvm_libc_20_0_0_git::internal::strdup<char>(char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/string/allocating_string_utils.h:26:16
    #5 0x55c209ae1c05 in __llvm_libc_20_0_0_git::strdup(char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/string/strdup.cpp:21:14
    #6 0x55c209adf790 in LlvmLibcStrDupTest_EmptyString::Run() /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/src/string/strdup_test.cpp:18:18
    #7 0x55c209ae9d27 in __llvm_libc_20_0_0_git::testing::Test::runTests(__llvm_libc_20_0_0_git::testing::TestOptions const&) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/UnitTest/LibcTest.cpp:165:8
    #8 0x55c209b27438 in main /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/UnitTest/LibcTestMain.cpp:59:10
    #9 0x7fbb29e46249  (/lib/x86_64-linux-gnu/libc.so.6+0x27249) (BuildId: 79005c16293efa45b441fed45f4f29b138557e9e)

0x55c209b3e680 is located 32 bytes to the left of global variable '<string literal>' defined in '/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/src/string/strdup_test.cpp:19:3' (0x55c209b3e6a0) of size 2
  '<string literal>' is ascii string '0'
0x55c209b3e681 is located 0 bytes to the right of global variable '<string literal>' defined in '/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/src/string/strdup_test.cpp:16:23' (0x55c209b3e680) of size 1
  '<string literal>' is ascii string ''
SUMMARY: AddressSanitizer: global-buffer-overflow /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/string/memory_utils/x86_64/inline_strlen.h:47:15 in unsigned int __llvm_libc_20_0_0_git::string_length_internal::compare_and_mask<long long vector[2], unsigned int>(long long vector[2] const*)
Shadow bytes around the buggy address:
  0x0ab8c135fc80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab8c135fc90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab8c135fca0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab8c135fcb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab8c135fcc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0ab8c135fcd0:[01]f9 f9 f9 02 f9 f9 f9 00 00 00 05 f9 f9 f9 f9
  0x0ab8c135fce0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab8c135fcf0: 00 02 f9 f9 f9 f9 f9 f9 07 f9 f9 f9 00 00 00 05
  0x0ab8c135fd00: f9 f9 f9 f9 06 f9 f9 f9 00 00 00 00 01 f9 f9 f9
  0x0ab8c135fd10: f9 f9 f9 f9 04 f9 f9 f9 00 00 00 00 01 f9 f9 f9
  0x0ab8c135fd20: f9 f9 f9 f9 00 00 00 07 f9 f9 f9 f9 00 00 00 05
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa

@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 20, 2025

LLVM Buildbot has detected a new failure on builder libc-x86_64-debian-fullbuild-dbg-asan running on libc-x86_64-debian-fullbuild while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/171/builds/28812

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[ RUN      ] LlvmLibcStrCSpnTest.ComplementarySpanForEachIndividualCharacter
[       OK ] LlvmLibcStrCSpnTest.ComplementarySpanForEachIndividualCharacter (6 us)
[ RUN      ] LlvmLibcStrCSpnTest.ComplementarySpanIsStringLengthIfNoCharacterFound
[       OK ] LlvmLibcStrCSpnTest.ComplementarySpanIsStringLengthIfNoCharacterFound (4 us)
[ RUN      ] LlvmLibcStrCSpnTest.DuplicatedCharactersNotPartOfComplementarySpan
[       OK ] LlvmLibcStrCSpnTest.DuplicatedCharactersNotPartOfComplementarySpan (5 us)
Ran 4 tests.  PASS: 4  FAIL: 0
[1105/1418] Linking CXX executable libc/test/src/string/libc.test.src.string.strsep_test.__unit__.__build__
[1106/1418] Linking CXX executable libc/test/src/string/libc.test.src.string.strtok_r_test.__unit__.__build__
[1107/1418] Running unit test libc.test.src.search.hsearch_test.__NO_EXPLICIT_SIMD_OPT
FAILED: libc/test/src/search/CMakeFiles/libc.test.src.search.hsearch_test.__NO_EXPLICIT_SIMD_OPT /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/build/libc/test/src/search/CMakeFiles/libc.test.src.search.hsearch_test.__NO_EXPLICIT_SIMD_OPT 
cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/build/libc/test/src/search && /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/build/libc/test/src/search/libc.test.src.search.hsearch_test.__NO_EXPLICIT_SIMD_OPT.__build__
[==========] Running 7 tests from 1 test suite.
[ RUN      ] LlvmLibcHsearchTest.CreateTooLarge
[       OK ] LlvmLibcHsearchTest.CreateTooLarge (22 us)
[ RUN      ] LlvmLibcHSearchTest.CreateInvalid
[       OK ] LlvmLibcHSearchTest.CreateInvalid (3 us)
[ RUN      ] LlvmLibcHSearchTest.CreateValid
[       OK ] LlvmLibcHSearchTest.CreateValid (127 us)
[ RUN      ] LlvmLibcHSearchTest.GrowFromZero
=================================================================
==1505737==ERROR: AddressSanitizer: global-buffer-overflow on address 0x5616f3e97c10 at pc 0x5616f3dfd4db bp 0x7ffef3361db0 sp 0x7ffef3361da8
READ of size 16 at 0x5616f3e97c10 thread T0
    #0 0x5616f3dfd4da in unsigned int __llvm_libc_20_0_0_git::string_length_internal::compare_and_mask<long long vector[2], unsigned int>(long long vector[2] const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/string/memory_utils/x86_64/inline_strlen.h:47:15
    #1 0x5616f3dfd440 in unsigned long __llvm_libc_20_0_0_git::string_length_internal::string_length_vector<long long vector[2], unsigned int, &(unsigned int __llvm_libc_20_0_0_git::string_length_internal::compare_and_mask<long long vector[2], unsigned int>(long long vector[2] const*))>(char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/string/memory_utils/x86_64/inline_strlen.h:36:11
    #2 0x5616f3dff8e4 in __llvm_libc_20_0_0_git::string_length_internal::sse2::string_length(char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/string/memory_utils/x86_64/inline_strlen.h:55:10
    #3 0x5616f3dfe944 in unsigned long __llvm_libc_20_0_0_git::internal::string_length<char>(char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/string/string_utils.h:110:12
    #4 0x5616f3dfd9f7 in __llvm_libc_20_0_0_git::internal::HashTable::oneshot_hash(char const*) const /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/__support/HashTable/table.h:180:24
    #5 0x5616f3dfd7d3 in __llvm_libc_20_0_0_git::internal::HashTable::insert(__llvm_libc_20_0_0_git::internal::HashTable*&, entry) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/__support/HashTable/table.h:349:31
    #6 0x5616f3e07f1a in __llvm_libc_20_0_0_git::hsearch(entry, ACTION) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/search/hsearch.cpp:40:15
    #7 0x5616f3df5b12 in LlvmLibcHSearchTest_GrowFromZero::Run() /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/src/search/hsearch_test.cpp:57:23
    #8 0x5616f3e0c717 in __llvm_libc_20_0_0_git::testing::Test::runTests(__llvm_libc_20_0_0_git::testing::TestOptions const&) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/UnitTest/LibcTest.cpp:165:8
    #9 0x5616f3e4ad18 in main /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/UnitTest/LibcTestMain.cpp:59:10
    #10 0x7f60b3366249 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16

0x5616f3e97c10 is located 48 bytes to the left of global variable 'search_data2' defined in '/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/src/search/hsearch_test.cpp:45:6' (0x5616f3e97c40) of size 67
  'search_data2' is ascii string '@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!###########$$$$$$$$$$^^^^^^&&&&&&&&'
0x5616f3e97c15 is located 0 bytes to the right of global variable 'search_data' defined in '/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/src/search/hsearch_test.cpp:40:6' (0x5616f3e97b60) of size 181
  'search_data' is ascii string '1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz'
SUMMARY: AddressSanitizer: global-buffer-overflow /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/string/memory_utils/x86_64/inline_strlen.h:47:15 in unsigned int __llvm_libc_20_0_0_git::string_length_internal::compare_and_mask<long long vector[2], unsigned int>(long long vector[2] const*)
Shadow bytes around the buggy address:
  0x0ac35e7caf30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac35e7caf40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac35e7caf50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac35e7caf60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac35e7caf70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0ac35e7caf80: 00 00[05]f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x0ac35e7caf90: 03 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x0ac35e7cafa0: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
Step 8 (libc-unit-tests) failure: libc-unit-tests (failure)
...
[ RUN      ] LlvmLibcStrCSpnTest.ComplementarySpanForEachIndividualCharacter
[       OK ] LlvmLibcStrCSpnTest.ComplementarySpanForEachIndividualCharacter (6 us)
[ RUN      ] LlvmLibcStrCSpnTest.ComplementarySpanIsStringLengthIfNoCharacterFound
[       OK ] LlvmLibcStrCSpnTest.ComplementarySpanIsStringLengthIfNoCharacterFound (4 us)
[ RUN      ] LlvmLibcStrCSpnTest.DuplicatedCharactersNotPartOfComplementarySpan
[       OK ] LlvmLibcStrCSpnTest.DuplicatedCharactersNotPartOfComplementarySpan (5 us)
Ran 4 tests.  PASS: 4  FAIL: 0
[1105/1418] Linking CXX executable libc/test/src/string/libc.test.src.string.strsep_test.__unit__.__build__
[1106/1418] Linking CXX executable libc/test/src/string/libc.test.src.string.strtok_r_test.__unit__.__build__
[1107/1418] Running unit test libc.test.src.search.hsearch_test.__NO_EXPLICIT_SIMD_OPT
FAILED: libc/test/src/search/CMakeFiles/libc.test.src.search.hsearch_test.__NO_EXPLICIT_SIMD_OPT /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/build/libc/test/src/search/CMakeFiles/libc.test.src.search.hsearch_test.__NO_EXPLICIT_SIMD_OPT 
cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/build/libc/test/src/search && /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/build/libc/test/src/search/libc.test.src.search.hsearch_test.__NO_EXPLICIT_SIMD_OPT.__build__
[==========] Running 7 tests from 1 test suite.
[ RUN      ] LlvmLibcHsearchTest.CreateTooLarge
[       OK ] LlvmLibcHsearchTest.CreateTooLarge (22 us)
[ RUN      ] LlvmLibcHSearchTest.CreateInvalid
[       OK ] LlvmLibcHSearchTest.CreateInvalid (3 us)
[ RUN      ] LlvmLibcHSearchTest.CreateValid
[       OK ] LlvmLibcHSearchTest.CreateValid (127 us)
[ RUN      ] LlvmLibcHSearchTest.GrowFromZero
=================================================================
==1505737==ERROR: AddressSanitizer: global-buffer-overflow on address 0x5616f3e97c10 at pc 0x5616f3dfd4db bp 0x7ffef3361db0 sp 0x7ffef3361da8
READ of size 16 at 0x5616f3e97c10 thread T0
    #0 0x5616f3dfd4da in unsigned int __llvm_libc_20_0_0_git::string_length_internal::compare_and_mask<long long vector[2], unsigned int>(long long vector[2] const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/string/memory_utils/x86_64/inline_strlen.h:47:15
    #1 0x5616f3dfd440 in unsigned long __llvm_libc_20_0_0_git::string_length_internal::string_length_vector<long long vector[2], unsigned int, &(unsigned int __llvm_libc_20_0_0_git::string_length_internal::compare_and_mask<long long vector[2], unsigned int>(long long vector[2] const*))>(char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/string/memory_utils/x86_64/inline_strlen.h:36:11
    #2 0x5616f3dff8e4 in __llvm_libc_20_0_0_git::string_length_internal::sse2::string_length(char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/string/memory_utils/x86_64/inline_strlen.h:55:10
    #3 0x5616f3dfe944 in unsigned long __llvm_libc_20_0_0_git::internal::string_length<char>(char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/string/string_utils.h:110:12
    #4 0x5616f3dfd9f7 in __llvm_libc_20_0_0_git::internal::HashTable::oneshot_hash(char const*) const /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/__support/HashTable/table.h:180:24
    #5 0x5616f3dfd7d3 in __llvm_libc_20_0_0_git::internal::HashTable::insert(__llvm_libc_20_0_0_git::internal::HashTable*&, entry) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/__support/HashTable/table.h:349:31
    #6 0x5616f3e07f1a in __llvm_libc_20_0_0_git::hsearch(entry, ACTION) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/search/hsearch.cpp:40:15
    #7 0x5616f3df5b12 in LlvmLibcHSearchTest_GrowFromZero::Run() /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/src/search/hsearch_test.cpp:57:23
    #8 0x5616f3e0c717 in __llvm_libc_20_0_0_git::testing::Test::runTests(__llvm_libc_20_0_0_git::testing::TestOptions const&) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/UnitTest/LibcTest.cpp:165:8
    #9 0x5616f3e4ad18 in main /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/UnitTest/LibcTestMain.cpp:59:10
    #10 0x7f60b3366249 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16

0x5616f3e97c10 is located 48 bytes to the left of global variable 'search_data2' defined in '/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/src/search/hsearch_test.cpp:45:6' (0x5616f3e97c40) of size 67
  'search_data2' is ascii string '@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!###########$$$$$$$$$$^^^^^^&&&&&&&&'
0x5616f3e97c15 is located 0 bytes to the right of global variable 'search_data' defined in '/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/src/search/hsearch_test.cpp:40:6' (0x5616f3e97b60) of size 181
  'search_data' is ascii string '1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz'
SUMMARY: AddressSanitizer: global-buffer-overflow /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/string/memory_utils/x86_64/inline_strlen.h:47:15 in unsigned int __llvm_libc_20_0_0_git::string_length_internal::compare_and_mask<long long vector[2], unsigned int>(long long vector[2] const*)
Shadow bytes around the buggy address:
  0x0ac35e7caf30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac35e7caf40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac35e7caf50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac35e7caf60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac35e7caf70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0ac35e7caf80: 00 00[05]f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x0ac35e7caf90: 03 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x0ac35e7cafa0: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9

jhuber6 added a commit that referenced this pull request Aug 20, 2025
jhuber6 added a commit to jhuber6/llvm-project that referenced this pull request Aug 20, 2025
jhuber6 added a commit to jhuber6/llvm-project that referenced this pull request Aug 20, 2025
jhuber6 added a commit to jhuber6/llvm-project that referenced this pull request Aug 20, 2025
jhuber6 added a commit to jhuber6/llvm-project that referenced this pull request Aug 20, 2025
jhuber6 added a commit to jhuber6/llvm-project that referenced this pull request Aug 20, 2025
jhuber6 added a commit to jhuber6/llvm-project that referenced this pull request Aug 20, 2025
jhuber6 added a commit to jhuber6/llvm-project that referenced this pull request Aug 21, 2025
jhuber6 added a commit to jhuber6/llvm-project that referenced this pull request Aug 21, 2025
jhuber6 added a commit that referenced this pull request Aug 21, 2025
#154602)" (#154640)

Reland afterr the sanitizer and arm32 builds complained.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants