Skip to content

Turn LIBC_COPT_STRING_UNSAFE_WIDE_READ on by default #144163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2025

Conversation

amykhuang
Copy link
Collaborator

Configure strlen to use unsafe implementation because it is faster.

Because this is undefined behavior it could cause sanitizers to fail.

@llvmbot
Copy link
Member

llvmbot commented Jun 13, 2025

@llvm/pr-subscribers-libc

Author: Amy Huang (amykhuang)

Changes

Configure strlen to use unsafe implementation because it is faster.

Because this is undefined behavior it could cause sanitizers to fail.


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

1 Files Affected:

  • (modified) libc/config/config.json (+1-1)
diff --git a/libc/config/config.json b/libc/config/config.json
index d53b2936edb07..0354b16997cdd 100644
--- a/libc/config/config.json
+++ b/libc/config/config.json
@@ -59,7 +59,7 @@
   },
   "string": {
     "LIBC_CONF_STRING_UNSAFE_WIDE_READ": {
-      "value": false,
+      "value": true,
       "doc": "Read more than a byte at a time to perform byte-string operations like strlen."
     },
     "LIBC_CONF_MEMSET_X86_USE_SOFTWARE_PREFETCHING": {

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

@amykhuang amykhuang merged commit a591bd2 into llvm:main Jun 13, 2025
15 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 13, 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/22940

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      ] LlvmLibcMemcmpTest.LhsBeforeRhsLexically
[       OK ] LlvmLibcMemcmpTest.LhsBeforeRhsLexically (2 us)
[ RUN      ] LlvmLibcMemcmpTest.LhsAfterRhsLexically
[       OK ] LlvmLibcMemcmpTest.LhsAfterRhsLexically (3 us)
[ RUN      ] LlvmLibcMemcmpTest.Issue77080
[       OK ] LlvmLibcMemcmpTest.Issue77080 (3 us)
[ RUN      ] LlvmLibcMemcmpTest.SizeSweep
[       OK ] LlvmLibcMemcmpTest.SizeSweep (63 ms)
Ran 6 tests.  PASS: 6  FAIL: 0
[927/1122] Running unit test libc.test.src.string.strcpy_test.__unit__
FAILED: libc/test/src/string/CMakeFiles/libc.test.src.string.strcpy_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.strcpy_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.strcpy_test.__unit__.__build__
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcStrCpyTest.EmptySrc
=================================================================
==30946==ERROR: AddressSanitizer: global-buffer-overflow on address 0x55a6b81c7680 at pc 0x55a6b816c191 bp 0x7ffd97e4b610 sp 0x7ffd97e4b608
READ of size 4 at 0x55a6b81c7680 thread T0
    #0 0x55a6b816c190 in unsigned long __llvm_libc_20_0_0_git::internal::string_length_wide_read<unsigned int>(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:73:26
    #1 0x55a6b816b134 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:92:12
    #2 0x55a6b816b0fb in __llvm_libc_20_0_0_git::strcpy(char*, char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/string/strcpy.cpp:22:17
    #3 0x55a6b8169786 in LlvmLibcStrCpyTest_EmptySrc::Run() /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/src/string/strcpy_test.cpp:17:18
    #4 0x55a6b8172a07 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
    #5 0x55a6b81af9c8 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
    #6 0x7fd87b966249  (/lib/x86_64-linux-gnu/libc.so.6+0x27249) (BuildId: 79005c16293efa45b441fed45f4f29b138557e9e)

0x55a6b81c7680 is located 32 bytes to the left of global variable '__const._ZN27LlvmLibcStrCpyTest_EmptySrc3RunEv.dest' defined in '/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/src/string/strcpy_test.cpp' (0x55a6b81c76a0) of size 4
  '__const._ZN27LlvmLibcStrCpyTest_EmptySrc3RunEv.dest' is ascii string 'abc'
0x55a6b81c7681 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/strcpy_test.cpp:14:23' (0x55a6b81c7680) 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/string_utils.h:73:26 in unsigned long __llvm_libc_20_0_0_git::internal::string_length_wide_read<unsigned int>(char const*)
Shadow bytes around the buggy address:
  0x0ab557030e80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab557030e90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab557030ea0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab557030eb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab557030ec0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0ab557030ed0:[01]f9 f9 f9 04 f9 f9 f9 05 f9 f9 f9 07 f9 f9 f9
  0x0ab557030ee0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab557030ef0: 00 02 f9 f9 f9 f9 f9 f9 06 f9 f9 f9 04 f9 f9 f9
  0x0ab557030f00: 00 01 f9 f9 07 f9 f9 f9 00 01 f9 f9 00 00 00 06
  0x0ab557030f10: f9 f9 f9 f9 00 00 00 07 f9 f9 f9 f9 00 00 00 00
  0x0ab557030f20: f9 f9 f9 f9 00 00 00 04 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
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
Step 7 (libc-unit-tests) failure: libc-unit-tests (failure)
...
[ RUN      ] LlvmLibcMemcmpTest.LhsBeforeRhsLexically
[       OK ] LlvmLibcMemcmpTest.LhsBeforeRhsLexically (2 us)
[ RUN      ] LlvmLibcMemcmpTest.LhsAfterRhsLexically
[       OK ] LlvmLibcMemcmpTest.LhsAfterRhsLexically (3 us)
[ RUN      ] LlvmLibcMemcmpTest.Issue77080
[       OK ] LlvmLibcMemcmpTest.Issue77080 (3 us)
[ RUN      ] LlvmLibcMemcmpTest.SizeSweep
[       OK ] LlvmLibcMemcmpTest.SizeSweep (63 ms)
Ran 6 tests.  PASS: 6  FAIL: 0
[927/1122] Running unit test libc.test.src.string.strcpy_test.__unit__
FAILED: libc/test/src/string/CMakeFiles/libc.test.src.string.strcpy_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.strcpy_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.strcpy_test.__unit__.__build__
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcStrCpyTest.EmptySrc
=================================================================
==30946==ERROR: AddressSanitizer: global-buffer-overflow on address 0x55a6b81c7680 at pc 0x55a6b816c191 bp 0x7ffd97e4b610 sp 0x7ffd97e4b608
READ of size 4 at 0x55a6b81c7680 thread T0
    #0 0x55a6b816c190 in unsigned long __llvm_libc_20_0_0_git::internal::string_length_wide_read<unsigned int>(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:73:26
    #1 0x55a6b816b134 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:92:12
    #2 0x55a6b816b0fb in __llvm_libc_20_0_0_git::strcpy(char*, char const*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/string/strcpy.cpp:22:17
    #3 0x55a6b8169786 in LlvmLibcStrCpyTest_EmptySrc::Run() /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/src/string/strcpy_test.cpp:17:18
    #4 0x55a6b8172a07 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
    #5 0x55a6b81af9c8 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
    #6 0x7fd87b966249  (/lib/x86_64-linux-gnu/libc.so.6+0x27249) (BuildId: 79005c16293efa45b441fed45f4f29b138557e9e)

0x55a6b81c7680 is located 32 bytes to the left of global variable '__const._ZN27LlvmLibcStrCpyTest_EmptySrc3RunEv.dest' defined in '/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/src/string/strcpy_test.cpp' (0x55a6b81c76a0) of size 4
  '__const._ZN27LlvmLibcStrCpyTest_EmptySrc3RunEv.dest' is ascii string 'abc'
0x55a6b81c7681 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/strcpy_test.cpp:14:23' (0x55a6b81c7680) 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/string_utils.h:73:26 in unsigned long __llvm_libc_20_0_0_git::internal::string_length_wide_read<unsigned int>(char const*)
Shadow bytes around the buggy address:
  0x0ab557030e80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab557030e90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab557030ea0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab557030eb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab557030ec0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0ab557030ed0:[01]f9 f9 f9 04 f9 f9 f9 05 f9 f9 f9 07 f9 f9 f9
  0x0ab557030ee0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab557030ef0: 00 02 f9 f9 f9 f9 f9 f9 06 f9 f9 f9 04 f9 f9 f9
  0x0ab557030f00: 00 01 f9 f9 07 f9 f9 f9 00 01 f9 f9 00 00 00 06
  0x0ab557030f10: f9 f9 f9 f9 00 00 00 07 f9 f9 f9 f9 00 00 00 00
  0x0ab557030f20: f9 f9 f9 f9 00 00 00 04 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
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 13, 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/23876

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      ] LlvmLibcFMaxTest.InfArg
[       OK ] LlvmLibcFMaxTest.InfArg (16 us)
[ RUN      ] LlvmLibcFMaxTest.NegInfArg
[       OK ] LlvmLibcFMaxTest.NegInfArg (12 us)
[ RUN      ] LlvmLibcFMaxTest.BothZero
[       OK ] LlvmLibcFMaxTest.BothZero (9 us)
[ RUN      ] LlvmLibcFMaxTest.Range
[       OK ] LlvmLibcFMaxTest.Range (379 ms)
Ran 5 tests.  PASS: 5  FAIL: 0
[276/1270] Running unit test libc.test.src.__support.HashTable.table_test.__unit__.__NO_EXPLICIT_SIMD_OPT
FAILED: libc/test/src/__support/HashTable/CMakeFiles/libc.test.src.__support.HashTable.table_test.__unit__.__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/__support/HashTable/CMakeFiles/libc.test.src.__support.HashTable.table_test.__unit__.__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/__support/HashTable && /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/build/libc/test/src/__support/HashTable/libc.test.src.__support.HashTable.table_test.__unit__.__NO_EXPLICIT_SIMD_OPT.__build__
[==========] Running 4 tests from 1 test suite.
[ RUN      ] LlvmLibcTableTest.AllocationAndDeallocation
=================================================================
==359352==ERROR: AddressSanitizer: global-buffer-overflow on address 0x5628d0692700 at pc 0x5628d0638eb1 bp 0x7ffdce8f2640 sp 0x7ffdce8f2638
READ of size 4 at 0x5628d0692700 thread T0
    #0 0x5628d0638eb0 in unsigned long __llvm_libc_20_0_0_git::internal::string_length_wide_read<unsigned int>(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:73:26
    #1 0x5628d0638da4 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:92:12
    #2 0x5628d0638d89 in __llvm_libc_20_0_0_git::strlen(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/strlen.cpp:22:10
    #3 0x5628d06313aa 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:179:24
    #4 0x5628d062e410 in __llvm_libc_20_0_0_git::internal::HashTable::find(char 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:340:24
    #5 0x5628d062aadd in __llvm_libc_20_0_0_git::internal::LlvmLibcTableTest_AllocationAndDeallocation::Run() /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/src/__support/HashTable/table_test.cpp:26:7
    #6 0x5628d063d557 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
    #7 0x5628d067b408 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
    #8 0x7fe547c46249 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16

0x5628d0692700 is located 32 bytes to the left of global variable '<string literal>' 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/__support/HashTable/table_test.cpp:19:37' (0x5628d0692720) of size 2
  '<string literal>' is ascii string 'a'
0x5628d0692701 is located 0 bytes to the right of global variable '<string literal>' 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/__support/HashTable/table_test.cpp:19:25' (0x5628d0692700) of size 1
  '<string literal>' is ascii string ''
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/string_utils.h:73:26 in unsigned long __llvm_libc_20_0_0_git::internal::string_length_wide_read<unsigned int>(char const*)
Shadow bytes around the buggy address:
  0x0ac59a0ca490: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac59a0ca4a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac59a0ca4b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac59a0ca4c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac59a0ca4d0: 00 00 00 00 00 00 00 00 00 00 00 f9 f9 f9 f9 f9
=>0x0ac59a0ca4e0:[01]f9 f9 f9 02 f9 f9 f9 03 f9 f9 f9 04 f9 f9 f9
  0x0ac59a0ca4f0: 05 f9 f9 f9 06 f9 f9 f9 07 f9 f9 f9 00 f9 f9 f9
  0x0ac59a0ca500: 00 01 f9 f9 00 02 f9 f9 00 03 f9 f9 06 f9 f9 f9
  0x0ac59a0ca510: 00 00 00 00 02 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
  0x0ac59a0ca520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac59a0ca530: 00 02 f9 f9 f9 f9 f9 f9 00 00 01 f9 f9 f9 f9 f9
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
  Freed heap region:       fd
Step 8 (libc-unit-tests) failure: libc-unit-tests (failure)
...
[ RUN      ] LlvmLibcFMaxTest.InfArg
[       OK ] LlvmLibcFMaxTest.InfArg (16 us)
[ RUN      ] LlvmLibcFMaxTest.NegInfArg
[       OK ] LlvmLibcFMaxTest.NegInfArg (12 us)
[ RUN      ] LlvmLibcFMaxTest.BothZero
[       OK ] LlvmLibcFMaxTest.BothZero (9 us)
[ RUN      ] LlvmLibcFMaxTest.Range
[       OK ] LlvmLibcFMaxTest.Range (379 ms)
Ran 5 tests.  PASS: 5  FAIL: 0
[276/1270] Running unit test libc.test.src.__support.HashTable.table_test.__unit__.__NO_EXPLICIT_SIMD_OPT
FAILED: libc/test/src/__support/HashTable/CMakeFiles/libc.test.src.__support.HashTable.table_test.__unit__.__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/__support/HashTable/CMakeFiles/libc.test.src.__support.HashTable.table_test.__unit__.__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/__support/HashTable && /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/build/libc/test/src/__support/HashTable/libc.test.src.__support.HashTable.table_test.__unit__.__NO_EXPLICIT_SIMD_OPT.__build__
[==========] Running 4 tests from 1 test suite.
[ RUN      ] LlvmLibcTableTest.AllocationAndDeallocation
=================================================================
==359352==ERROR: AddressSanitizer: global-buffer-overflow on address 0x5628d0692700 at pc 0x5628d0638eb1 bp 0x7ffdce8f2640 sp 0x7ffdce8f2638
READ of size 4 at 0x5628d0692700 thread T0
    #0 0x5628d0638eb0 in unsigned long __llvm_libc_20_0_0_git::internal::string_length_wide_read<unsigned int>(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:73:26
    #1 0x5628d0638da4 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:92:12
    #2 0x5628d0638d89 in __llvm_libc_20_0_0_git::strlen(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/strlen.cpp:22:10
    #3 0x5628d06313aa 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:179:24
    #4 0x5628d062e410 in __llvm_libc_20_0_0_git::internal::HashTable::find(char 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:340:24
    #5 0x5628d062aadd in __llvm_libc_20_0_0_git::internal::LlvmLibcTableTest_AllocationAndDeallocation::Run() /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/src/__support/HashTable/table_test.cpp:26:7
    #6 0x5628d063d557 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
    #7 0x5628d067b408 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
    #8 0x7fe547c46249 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16

0x5628d0692700 is located 32 bytes to the left of global variable '<string literal>' 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/__support/HashTable/table_test.cpp:19:37' (0x5628d0692720) of size 2
  '<string literal>' is ascii string 'a'
0x5628d0692701 is located 0 bytes to the right of global variable '<string literal>' 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/__support/HashTable/table_test.cpp:19:25' (0x5628d0692700) of size 1
  '<string literal>' is ascii string ''
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/string_utils.h:73:26 in unsigned long __llvm_libc_20_0_0_git::internal::string_length_wide_read<unsigned int>(char const*)
Shadow bytes around the buggy address:
  0x0ac59a0ca490: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac59a0ca4a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac59a0ca4b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac59a0ca4c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac59a0ca4d0: 00 00 00 00 00 00 00 00 00 00 00 f9 f9 f9 f9 f9
=>0x0ac59a0ca4e0:[01]f9 f9 f9 02 f9 f9 f9 03 f9 f9 f9 04 f9 f9 f9
  0x0ac59a0ca4f0: 05 f9 f9 f9 06 f9 f9 f9 07 f9 f9 f9 00 f9 f9 f9
  0x0ac59a0ca500: 00 01 f9 f9 00 02 f9 f9 00 03 f9 f9 06 f9 f9 f9
  0x0ac59a0ca510: 00 00 00 00 02 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
  0x0ac59a0ca520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac59a0ca530: 00 02 f9 f9 f9 f9 f9 f9 00 00 01 f9 f9 f9 f9 f9
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
  Freed heap region:       fd

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 13, 2025

LLVM Buildbot has detected a new failure on builder openmp-offload-amdgpu-runtime-2 running on rocm-worker-hw-02 while building libc at step 10 "Add check check-libc-amdgcn-amd-amdhsa".

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

Here is the relevant piece of the build log for the reference
Step 10 (Add check check-libc-amdgcn-amd-amdhsa) failure: test (failure)
...
Ran 1 tests.  PASS: 1  FAIL: 0
[2439/2807] Running hermetic test libc.test.src.math.smoke.logf_test.__hermetic__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcLogfTest.SpecialNumbers
[       OK ] LlvmLibcLogfTest.SpecialNumbers (23 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[2440/2807] Linking CXX executable libc/test/src/stdio/libc.test.src.stdio.fprintf_test.__hermetic__.__build__
[2441/2807] Linking CXX executable libc/test/src/string/libc.test.src.string.memchr_test.__hermetic__.__build__
[2442/2807] Linking CXX executable libc/test/src/math/smoke/libc.test.src.math.smoke.scalbn_test.__hermetic__.__build__
[2443/2807] Linking CXX executable libc/test/src/string/libc.test.src.string.stpcpy_test.__hermetic__.__build__
FAILED: libc/test/src/string/libc.test.src.string.stpcpy_test.__hermetic__.__build__ 
: && /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/clang++ --target=amdgcn-amd-amdhsa -O3 -DNDEBUG --target=amdgcn-amd-amdhsa -Wno-multi-gpu -mcpu=native -flto -Wl,-mllvm,-amdgpu-lower-global-ctor-dtor=0 -nostdlib -static -Wl,-mllvm,-amdhsa-code-object-version=6 libc/startup/gpu/amdgpu/CMakeFiles/libc.startup.gpu.amdgpu.crt1.dir/start.cpp.o libc/test/src/string/CMakeFiles/libc.test.src.string.stpcpy_test.__hermetic__.__build__.dir/stpcpy_test.cpp.o -o libc/test/src/string/libc.test.src.string.stpcpy_test.__hermetic__.__build__  libc/test/UnitTest/libLibcTest.hermetic.a  libc/test/UnitTest/libLibcHermeticTestSupport.hermetic.a  libc/test/src/string/liblibc.test.src.string.stpcpy_test.__hermetic__.libc.a && :
ld.lld: error: Illegal instruction detected: Operand has incorrect register class.
renamable $sgpr8 = S_CSELECT_B32 0, killed $vgpr2, implicit $scc
clang++: error: ld.lld command failed with exit code 1 (use -v to see invocation)
[2444/2807] Running hermetic test libc.test.src.string.memccpy_test.__hermetic__
[==========] Running 6 tests from 1 test suite.
[ RUN      ] LlvmLibcMemccpyTest.UntouchedUnrelatedEnd
[       OK ] LlvmLibcMemccpyTest.UntouchedUnrelatedEnd (9 us)
[ RUN      ] LlvmLibcMemccpyTest.UntouchedStartsWithEnd
[       OK ] LlvmLibcMemccpyTest.UntouchedStartsWithEnd (3 us)
[ RUN      ] LlvmLibcMemccpyTest.CopyOneUnrelatedEnd
[       OK ] LlvmLibcMemccpyTest.CopyOneUnrelatedEnd (6 us)
[ RUN      ] LlvmLibcMemccpyTest.CopyOneStartsWithEnd
[       OK ] LlvmLibcMemccpyTest.CopyOneStartsWithEnd (5 us)
[ RUN      ] LlvmLibcMemccpyTest.CopyTwoUnrelatedEnd
[       OK ] LlvmLibcMemccpyTest.CopyTwoUnrelatedEnd (4 us)
[ RUN      ] LlvmLibcMemccpyTest.CopyTwoStartsWithEnd
[       OK ] LlvmLibcMemccpyTest.CopyTwoStartsWithEnd (5 us)
Ran 6 tests.  PASS: 6  FAIL: 0
[2445/2807] Running hermetic test libc.test.src.math.smoke.logf16_test.__hermetic__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcLogf16Test.SpecialNumbers
[       OK ] LlvmLibcLogf16Test.SpecialNumbers (29 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[2446/2807] Linking CXX executable libc/test/src/string/libc.test.src.string.strdup_test.__hermetic__.__build__
[2447/2807] Linking CXX executable libc/test/src/stdlib/libc.test.src.stdlib.heap_sort_test.__hermetic__.__build__
[2448/2807] Running hermetic test libc.test.src.math.smoke.log2_test.__hermetic__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcLog2Test.SpecialNumbers
[       OK ] LlvmLibcLog2Test.SpecialNumbers (26 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[2449/2807] Linking CXX executable libc/test/src/string/libc.test.src.string.stpncpy_test.__hermetic__.__build__
[2450/2807] Linking CXX executable libc/test/src/time/libc.test.src.time.clock_test.__hermetic__.__build__
[2451/2807] Linking CXX executable libc/test/include/libc.test.include.fpclassifyf_test.__hermetic__.__build__
[2452/2807] Linking CXX executable libc/test/include/libc.test.include.issubnormal_test.__hermetic__.__build__
[2453/2807] Linking CXX executable libc/test/include/libc.test.include.isnormall_test.__hermetic__.__build__
[2454/2807] Linking CXX executable libc/test/src/stdio/libc.test.src.stdio.vsscanf_test.__hermetic__.__build__
[2455/2807] Linking CXX executable libc/test/src/math/smoke/libc.test.src.math.smoke.fdivl_test.__hermetic__.__build__

amykhuang added a commit that referenced this pull request Jun 13, 2025
amykhuang added a commit that referenced this pull request Jun 13, 2025
Reverts #144163 because for some reason I didn't
realize there are ASan tests.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Jun 13, 2025
…lt" (#144167)

Reverts llvm/llvm-project#144163 because for some reason I didn't
realize there are ASan tests.
tomtor pushed a commit to tomtor/llvm-project that referenced this pull request Jun 14, 2025
Configure strlen to use unsafe implementation because it is faster.

Because this is undefined behavior it could cause sanitizers to fail.
tomtor pushed a commit to tomtor/llvm-project that referenced this pull request Jun 14, 2025
…44167)

Reverts llvm#144163 because for some reason I didn't
realize there are ASan tests.
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