[libc-commits] [libc] [libc] Fix readlink tests on 32-bit systems (PR #97850)

LLVM Continuous Integration via libc-commits libc-commits at lists.llvm.org
Fri Jul 5 11:22:17 PDT 2024


llvm-ci wrote:

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/1485

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)
...
[688/695] Building CXX object projects/libc/test/src/unistd/CMakeFiles/libc.test.src.unistd.readlinkat_test.__build__.dir/readlinkat_test.cpp.o
[689/695] Building CXX object projects/libc/test/src/unistd/CMakeFiles/libc.test.src.unistd.readlink_test.__build__.dir/readlink_test.cpp.o
[690/695] Running unit test libc.test.src.time.nanosleep_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcNanosleep.SmokeTest
[       OK ] LlvmLibcNanosleep.SmokeTest (45 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[691/695] Linking CXX executable projects/libc/test/src/unistd/libc.test.src.unistd.readlink_test.__build__
[692/695] Linking CXX executable projects/libc/test/src/unistd/libc.test.src.unistd.readlinkat_test.__build__
[693/695] Running unit test libc.test.src.unistd.readlink_test
FAILED: projects/libc/test/src/unistd/CMakeFiles/libc.test.src.unistd.readlink_test /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/build/projects/libc/test/src/unistd/CMakeFiles/libc.test.src.unistd.readlink_test 
cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/build/projects/libc/test/src/unistd && /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/build/projects/libc/test/src/unistd/libc.test.src.unistd.readlink_test.__build__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcReadlinkTest.CreateAndUnlink
=================================================================
==2592106==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffdbee5b728 at pc 0x555f9be40d55 bp 0x7ffdbee5b410 sp 0x7ffdbee5b408
READ of size 1 at 0x7ffdbee5b728 thread T0
    #0 0x555f9be40d54 in __llvm_libc_19_0_0_git::cpp::string_view::compareMemory(char const*, char const*, unsigned long) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/__support/CPP/string_view.h:34:27
    #1 0x555f9be40d54 in __llvm_libc_19_0_0_git::cpp::string_view::equals(__llvm_libc_19_0_0_git::cpp::string_view) const /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/__support/CPP/string_view.h:47:13
    #2 0x555f9be40d54 in __llvm_libc_19_0_0_git::cpp::string_view::operator==(__llvm_libc_19_0_0_git::cpp::string_view) const /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/__support/CPP/string_view.h:111:65
    #3 0x555f9be40d54 in bool __llvm_libc_19_0_0_git::testing::internal::test<__llvm_libc_19_0_0_git::cpp::string_view>(__llvm_libc_19_0_0_git::testing::internal::RunContext*, __llvm_libc_19_0_0_git::testing::TestCond, __llvm_libc_19_0_0_git::cpp::string_view, __llvm_libc_19_0_0_git::cpp::string_view, char const*, char const*, __llvm_libc_19_0_0_git::testing::internal::Location) /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:93:34
    #4 0x555f9be29dd8 in bool __llvm_libc_19_0_0_git::testing::Test::test<__llvm_libc_19_0_0_git::cpp::string_view, 0>(__llvm_libc_19_0_0_git::testing::TestCond, __llvm_libc_19_0_0_git::cpp::string_view, __llvm_libc_19_0_0_git::cpp::string_view, char const*, char const*, __llvm_libc_19_0_0_git::testing::internal::Location) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/UnitTest/LibcTest.h:170:12
    #5 0x555f9be29dd8 in LlvmLibcReadlinkTest_CreateAndUnlink::Run() /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/src/unistd/readlink_test.cpp:38:3
    #6 0x555f9be2f610 in __llvm_libc_19_0_0_git::testing::Test::runTests(__llvm_libc_19_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 0x555f9be493f1 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:51:10
    #8 0x7f1c05767249  (/lib/x86_64-linux-gnu/libc.so.6+0x27249) (BuildId: 58254ca972028402bc40624f81388d85ec95f70d)

Address 0x7ffdbee5b728 is located in stack of thread T0 at offset 360 in frame
    #0 0x555f9be296cf in LlvmLibcReadlinkTest_CreateAndUnlink::Run() /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/src/unistd/readlink_test.cpp:20

  This frame has 9 object(s):
    [32, 48) 'agg.tmp3272'
    [64, 80) 'agg.tmp2262'
    [96, 112) 'agg.tmp1154'
    [128, 144) 'agg.tmp50'
    [160, 184) 'LINK_VAL' (line 23)
    [224, 248) 'LINK' (line 25)
    [288, 320) 'ref.tmp' (line 32)
    [352, 360) 'buf' (line 34) <== Memory access at offset 360 overflows this variable
    [384, 416) 'ref.tmp29' (line 40)
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/__support/CPP/string_view.h:34:27 in __llvm_libc_19_0_0_git::cpp::string_view::compareMemory(char const*, char const*, unsigned long)
Shadow bytes around the buggy address:
  0x100037dc3690: 00 00 00 00 00 00 00 00 00 f3 f3 f3 f3 f3 f3 f3
  0x100037dc36a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100037dc36b0: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 f8 f8 f2 f2
  0x100037dc36c0: 00 00 f2 f2 f8 f8 f2 f2 f8 f8 f2 f2 00 00 00 f2
  0x100037dc36d0: f2 f2 f2 f2 00 00 00 f2 f2 f2 f2 f2 f8 f8 f8 f8
Step 8 (libc-unit-tests) failure: libc-unit-tests (failure)
...
[688/695] Building CXX object projects/libc/test/src/unistd/CMakeFiles/libc.test.src.unistd.readlinkat_test.__build__.dir/readlinkat_test.cpp.o
[689/695] Building CXX object projects/libc/test/src/unistd/CMakeFiles/libc.test.src.unistd.readlink_test.__build__.dir/readlink_test.cpp.o
[690/695] Running unit test libc.test.src.time.nanosleep_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcNanosleep.SmokeTest
[       OK ] LlvmLibcNanosleep.SmokeTest (45 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[691/695] Linking CXX executable projects/libc/test/src/unistd/libc.test.src.unistd.readlink_test.__build__
[692/695] Linking CXX executable projects/libc/test/src/unistd/libc.test.src.unistd.readlinkat_test.__build__
[693/695] Running unit test libc.test.src.unistd.readlink_test
FAILED: projects/libc/test/src/unistd/CMakeFiles/libc.test.src.unistd.readlink_test /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/build/projects/libc/test/src/unistd/CMakeFiles/libc.test.src.unistd.readlink_test 
cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/build/projects/libc/test/src/unistd && /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/build/projects/libc/test/src/unistd/libc.test.src.unistd.readlink_test.__build__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcReadlinkTest.CreateAndUnlink
=================================================================
==2592106==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffdbee5b728 at pc 0x555f9be40d55 bp 0x7ffdbee5b410 sp 0x7ffdbee5b408
READ of size 1 at 0x7ffdbee5b728 thread T0
    #0 0x555f9be40d54 in __llvm_libc_19_0_0_git::cpp::string_view::compareMemory(char const*, char const*, unsigned long) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/__support/CPP/string_view.h:34:27
    #1 0x555f9be40d54 in __llvm_libc_19_0_0_git::cpp::string_view::equals(__llvm_libc_19_0_0_git::cpp::string_view) const /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/__support/CPP/string_view.h:47:13
    #2 0x555f9be40d54 in __llvm_libc_19_0_0_git::cpp::string_view::operator==(__llvm_libc_19_0_0_git::cpp::string_view) const /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/__support/CPP/string_view.h:111:65
    #3 0x555f9be40d54 in bool __llvm_libc_19_0_0_git::testing::internal::test<__llvm_libc_19_0_0_git::cpp::string_view>(__llvm_libc_19_0_0_git::testing::internal::RunContext*, __llvm_libc_19_0_0_git::testing::TestCond, __llvm_libc_19_0_0_git::cpp::string_view, __llvm_libc_19_0_0_git::cpp::string_view, char const*, char const*, __llvm_libc_19_0_0_git::testing::internal::Location) /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:93:34
    #4 0x555f9be29dd8 in bool __llvm_libc_19_0_0_git::testing::Test::test<__llvm_libc_19_0_0_git::cpp::string_view, 0>(__llvm_libc_19_0_0_git::testing::TestCond, __llvm_libc_19_0_0_git::cpp::string_view, __llvm_libc_19_0_0_git::cpp::string_view, char const*, char const*, __llvm_libc_19_0_0_git::testing::internal::Location) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/UnitTest/LibcTest.h:170:12
    #5 0x555f9be29dd8 in LlvmLibcReadlinkTest_CreateAndUnlink::Run() /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/src/unistd/readlink_test.cpp:38:3
    #6 0x555f9be2f610 in __llvm_libc_19_0_0_git::testing::Test::runTests(__llvm_libc_19_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 0x555f9be493f1 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:51:10
    #8 0x7f1c05767249  (/lib/x86_64-linux-gnu/libc.so.6+0x27249) (BuildId: 58254ca972028402bc40624f81388d85ec95f70d)

Address 0x7ffdbee5b728 is located in stack of thread T0 at offset 360 in frame
    #0 0x555f9be296cf in LlvmLibcReadlinkTest_CreateAndUnlink::Run() /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/test/src/unistd/readlink_test.cpp:20

  This frame has 9 object(s):
    [32, 48) 'agg.tmp3272'
    [64, 80) 'agg.tmp2262'
    [96, 112) 'agg.tmp1154'
    [128, 144) 'agg.tmp50'
    [160, 184) 'LINK_VAL' (line 23)
    [224, 248) 'LINK' (line 25)
    [288, 320) 'ref.tmp' (line 32)
    [352, 360) 'buf' (line 34) <== Memory access at offset 360 overflows this variable
    [384, 416) 'ref.tmp29' (line 40)
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg-asan/llvm-project/libc/src/__support/CPP/string_view.h:34:27 in __llvm_libc_19_0_0_git::cpp::string_view::compareMemory(char const*, char const*, unsigned long)
Shadow bytes around the buggy address:
  0x100037dc3690: 00 00 00 00 00 00 00 00 00 f3 f3 f3 f3 f3 f3 f3
  0x100037dc36a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100037dc36b0: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 f8 f8 f2 f2
  0x100037dc36c0: 00 00 f2 f2 f8 f8 f2 f2 f8 f8 f2 f2 00 00 00 f2
  0x100037dc36d0: f2 f2 f2 f2 00 00 00 f2 f2 f2 f2 f2 f8 f8 f8 f8

```

https://github.com/llvm/llvm-project/pull/97850


More information about the libc-commits mailing list