Skip to content

Conversation

@jtstogel
Copy link
Contributor

@jtstogel jtstogel commented Nov 3, 2025

This patch also configures fcntl lock tests to run with F_OFD_* command variants, as all existing lock tests do not exercise process-associated- or OFD-specific functionality.

@llvmbot
Copy link
Member

llvmbot commented Nov 3, 2025

@llvm/pr-subscribers-libc

Author: Jackson Stogel (jtstogel)

Changes

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

1 Files Affected:

  • (modified) libc/src/__support/OSUtil/linux/fcntl.cpp (+1-1)
diff --git a/libc/src/__support/OSUtil/linux/fcntl.cpp b/libc/src/__support/OSUtil/linux/fcntl.cpp
index bb76eee90efd2..08db4859c6417 100644
--- a/libc/src/__support/OSUtil/linux/fcntl.cpp
+++ b/libc/src/__support/OSUtil/linux/fcntl.cpp
@@ -66,7 +66,7 @@ ErrorOr<int> fcntl(int fd, int cmd, void *arg) {
         LIBC_NAMESPACE::syscall_impl<int>(FCNTL_SYSCALL_ID, fd, cmd, &flk64);
     // On failure, return
     if (ret < 0)
-      return Error(-1);
+      return Error(-ret);
     // Check for overflow, i.e. the offsets are not the same when cast
     // to off_t from off64_t.
     if (static_cast<off_t>(flk64.l_len) != flk64.l_len ||

@vonosmas
Copy link
Contributor

vonosmas commented Nov 3, 2025

Do we have a test for this?

@jtstogel jtstogel changed the title Return errno from F_OFD_SETLKW failure path in fcntl. Return errno from OFD failure paths in fcntl. Nov 3, 2025
@jtstogel
Copy link
Contributor Author

jtstogel commented Nov 3, 2025

Do we have a test for this?

There's an analogous test that checks F_GETFL, not the OFD variant. If you modify that test to specify F_OFD_GETLK, it fails before this patch.

TEST_F(LlvmLibcFcntlTest, UseAfterClose) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE_NAME = "testdata/fcntl_use_after_close.test";
auto TEST_FILE = libc_make_test_file_path(TEST_FILE_NAME);
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_CREAT | O_TRUNC | O_RDWR, S_IRWXU);
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
ASSERT_EQ(-1, LIBC_NAMESPACE::fcntl(fd, F_GETFL));
ASSERT_ERRNO_EQ(EBADF);
}

It looks like more generally none of the OFD paths are tested. Do we have parameterized testing for libc or an issue to add something like TEST_P?

@vonosmas
Copy link
Contributor

vonosmas commented Nov 3, 2025

Do we have a test for this?

There's an analogous test that checks F_GETFL, not the OFD variant. If you modify that test to specify F_OFD_GETLK, it fails before this patch.

TEST_F(LlvmLibcFcntlTest, UseAfterClose) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE_NAME = "testdata/fcntl_use_after_close.test";
auto TEST_FILE = libc_make_test_file_path(TEST_FILE_NAME);
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_CREAT | O_TRUNC | O_RDWR, S_IRWXU);
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
ASSERT_EQ(-1, LIBC_NAMESPACE::fcntl(fd, F_GETFL));
ASSERT_ERRNO_EQ(EBADF);
}

It looks like more generally none of the OFD paths are tested. Do we have parameterized testing for libc or an issue to add something like TEST_P?

@lntue to confirm, but I think we basically do ad-hoc parametrized testing in various places -- definitely for math functions with various rounding modes, but also for some stdlib routines:

#define STRTOL_TEST(name, func) \
using LlvmLibc##name##Test = StrtoTest<decltype(func("", nullptr, 0))>; \
TEST_F(LlvmLibc##name##Test, InvalidBase) { InvalidBase(func); } \

@lntue
Copy link
Contributor

lntue commented Nov 4, 2025

Do we have a test for this?

There's an analogous test that checks F_GETFL, not the OFD variant. If you modify that test to specify F_OFD_GETLK, it fails before this patch.

TEST_F(LlvmLibcFcntlTest, UseAfterClose) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE_NAME = "testdata/fcntl_use_after_close.test";
auto TEST_FILE = libc_make_test_file_path(TEST_FILE_NAME);
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_CREAT | O_TRUNC | O_RDWR, S_IRWXU);
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
ASSERT_EQ(-1, LIBC_NAMESPACE::fcntl(fd, F_GETFL));
ASSERT_ERRNO_EQ(EBADF);
}

It looks like more generally none of the OFD paths are tested. Do we have parameterized testing for libc or an issue to add something like TEST_P?

@lntue to confirm, but I think we basically do ad-hoc parametrized testing in various places -- definitely for math functions with various rounding modes, but also for some stdlib routines:

#define STRTOL_TEST(name, func) \
using LlvmLibc##name##Test = StrtoTest<decltype(func("", nullptr, 0))>; \
TEST_F(LlvmLibc##name##Test, InvalidBase) { InvalidBase(func); } \

+1 for small ad-hoc parametrizing tests when it makes sense, like when the behaviors / implementations won't diverge in the future.

@jtstogel jtstogel requested a review from vonosmas November 5, 2025 19:44
@jtstogel jtstogel changed the title Return errno from OFD failure paths in fcntl. [libc] Return errno from OFD failure paths in fcntl. Nov 5, 2025
@jtstogel jtstogel merged commit 81dede8 into llvm:main Nov 5, 2025
18 of 19 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 5, 2025

LLVM Buildbot has detected a new failure on builder libc-x86_64-debian-gcc-fullbuild-dbg 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/131/builds/33686

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)
...
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcSignbitTest.SpecialNumbers
[       OK ] LlvmLibcSignbitTest.SpecialNumbers (4 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[2783/2802] Running unit test libc.test.include.signbitf_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcSignbitTest.SpecialNumbers
[       OK ] LlvmLibcSignbitTest.SpecialNumbers (3 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[2784/2802] Running unit test libc.test.src.fcntl.fcntl_test
FAILED: libc/test/src/fcntl/CMakeFiles/libc.test.src.fcntl.fcntl_test /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/libc/test/src/fcntl/CMakeFiles/libc.test.src.fcntl.fcntl_test 
cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/libc/test/src/fcntl && /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/libc/test/src/fcntl/libc.test.src.fcntl.fcntl_test.__build__
[==========] Running 10 tests from 1 test suite.
[ RUN      ] LlvmLibcFcntlTest.FcntlDupfd
[       OK ] LlvmLibcFcntlTest.FcntlDupfd (51 us)
[ RUN      ] LlvmLibcFcntlTest.FcntlGetFl
[       OK ] LlvmLibcFcntlTest.FcntlGetFl (22 us)
[ RUN      ] LlvmLibcFcntlTest.FcntlSetFl
[       OK ] LlvmLibcFcntlTest.FcntlSetFl (26 us)
[ RUN      ] LlvmLibcFcntlProcessAssociatedLockTest.GetLkRead
[       OK ] LlvmLibcFcntlProcessAssociatedLockTest.GetLkRead (27 us)
[ RUN      ] LlvmLibcFcntlProcessAssociatedLockTest.GetLkWrite
[       OK ] LlvmLibcFcntlProcessAssociatedLockTest.GetLkWrite (50 us)
[ RUN      ] LlvmLibcFcntlProcessAssociatedLockTest.UseAfterClose
[       OK ] LlvmLibcFcntlProcessAssociatedLockTest.UseAfterClose (27 us)
[ RUN      ] LlvmLibcFcntlOpenFileDescriptionLockTest.GetLkRead
[       OK ] LlvmLibcFcntlOpenFileDescriptionLockTest.GetLkRead (21 us)
[ RUN      ] LlvmLibcFcntlOpenFileDescriptionLockTest.GetLkWrite
[       OK ] LlvmLibcFcntlOpenFileDescriptionLockTest.GetLkWrite (21 us)
[ RUN      ] LlvmLibcFcntlOpenFileDescriptionLockTest.UseAfterClose
Segmentation fault
[2785/2802] Running unit test libc.test.include.fpclassifyl_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcFpClassifyTest.SpecialNumbers
[       OK ] LlvmLibcFpClassifyTest.SpecialNumbers (8 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[2786/2802] Running unit test libc.test.include.iszerof_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcIsZeroTest.SpecialNumbers
[       OK ] LlvmLibcIsZeroTest.SpecialNumbers (4 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[2787/2802] Running unit test libc.test.include.iszerol_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcIsZeroTest.SpecialNumbers
[       OK ] LlvmLibcIsZeroTest.SpecialNumbers (6 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[2788/2802] Running unit test libc.test.include.netinet_in_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcNetinetInTest.IPPROTOMacro
Step 8 (libc-unit-tests) failure: libc-unit-tests (failure)
...
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcSignbitTest.SpecialNumbers
[       OK ] LlvmLibcSignbitTest.SpecialNumbers (4 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[2783/2802] Running unit test libc.test.include.signbitf_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcSignbitTest.SpecialNumbers
[       OK ] LlvmLibcSignbitTest.SpecialNumbers (3 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[2784/2802] Running unit test libc.test.src.fcntl.fcntl_test
FAILED: libc/test/src/fcntl/CMakeFiles/libc.test.src.fcntl.fcntl_test /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/libc/test/src/fcntl/CMakeFiles/libc.test.src.fcntl.fcntl_test 
cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/libc/test/src/fcntl && /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/libc/test/src/fcntl/libc.test.src.fcntl.fcntl_test.__build__
[==========] Running 10 tests from 1 test suite.
[ RUN      ] LlvmLibcFcntlTest.FcntlDupfd
[       OK ] LlvmLibcFcntlTest.FcntlDupfd (51 us)
[ RUN      ] LlvmLibcFcntlTest.FcntlGetFl
[       OK ] LlvmLibcFcntlTest.FcntlGetFl (22 us)
[ RUN      ] LlvmLibcFcntlTest.FcntlSetFl
[       OK ] LlvmLibcFcntlTest.FcntlSetFl (26 us)
[ RUN      ] LlvmLibcFcntlProcessAssociatedLockTest.GetLkRead
[       OK ] LlvmLibcFcntlProcessAssociatedLockTest.GetLkRead (27 us)
[ RUN      ] LlvmLibcFcntlProcessAssociatedLockTest.GetLkWrite
[       OK ] LlvmLibcFcntlProcessAssociatedLockTest.GetLkWrite (50 us)
[ RUN      ] LlvmLibcFcntlProcessAssociatedLockTest.UseAfterClose
[       OK ] LlvmLibcFcntlProcessAssociatedLockTest.UseAfterClose (27 us)
[ RUN      ] LlvmLibcFcntlOpenFileDescriptionLockTest.GetLkRead
[       OK ] LlvmLibcFcntlOpenFileDescriptionLockTest.GetLkRead (21 us)
[ RUN      ] LlvmLibcFcntlOpenFileDescriptionLockTest.GetLkWrite
[       OK ] LlvmLibcFcntlOpenFileDescriptionLockTest.GetLkWrite (21 us)
[ RUN      ] LlvmLibcFcntlOpenFileDescriptionLockTest.UseAfterClose
Segmentation fault
[2785/2802] Running unit test libc.test.include.fpclassifyl_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcFpClassifyTest.SpecialNumbers
[       OK ] LlvmLibcFpClassifyTest.SpecialNumbers (8 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[2786/2802] Running unit test libc.test.include.iszerof_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcIsZeroTest.SpecialNumbers
[       OK ] LlvmLibcIsZeroTest.SpecialNumbers (4 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[2787/2802] Running unit test libc.test.include.iszerol_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcIsZeroTest.SpecialNumbers
[       OK ] LlvmLibcIsZeroTest.SpecialNumbers (6 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[2788/2802] Running unit test libc.test.include.netinet_in_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcNetinetInTest.IPPROTOMacro

@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 5, 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/32458

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)
...
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcSharedMathTest.AllFloat
[       OK ] LlvmLibcSharedMathTest.AllFloat (86 us)
[ RUN      ] LlvmLibcSharedMathTest.AllDouble
[       OK ] LlvmLibcSharedMathTest.AllDouble (33 us)
[ RUN      ] LlvmLibcSharedMathTest.AllFloat128
[       OK ] LlvmLibcSharedMathTest.AllFloat128 (120 us)
Ran 3 tests.  PASS: 3  FAIL: 0
[2527/2533] Linking CXX executable libc/test/src/fcntl/libc.test.src.fcntl.fcntl_test.__build__
[2528/2533] Running unit test libc.test.src.fcntl.fcntl_test
FAILED: libc/test/src/fcntl/CMakeFiles/libc.test.src.fcntl.fcntl_test /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/libc/test/src/fcntl/CMakeFiles/libc.test.src.fcntl.fcntl_test 
cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/libc/test/src/fcntl && /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/libc/test/src/fcntl/libc.test.src.fcntl.fcntl_test.__build__
[==========] Running 10 tests from 1 test suite.
[ RUN      ] LlvmLibcFcntlTest.FcntlDupfd
[       OK ] LlvmLibcFcntlTest.FcntlDupfd (291 us)
[ RUN      ] LlvmLibcFcntlTest.FcntlGetFl
[       OK ] LlvmLibcFcntlTest.FcntlGetFl (72 us)
[ RUN      ] LlvmLibcFcntlTest.FcntlSetFl
[       OK ] LlvmLibcFcntlTest.FcntlSetFl (104 us)
[ RUN      ] LlvmLibcFcntlProcessAssociatedLockTest.GetLkRead
[       OK ] LlvmLibcFcntlProcessAssociatedLockTest.GetLkRead (176 us)
[ RUN      ] LlvmLibcFcntlProcessAssociatedLockTest.GetLkWrite
[       OK ] LlvmLibcFcntlProcessAssociatedLockTest.GetLkWrite (98 us)
[ RUN      ] LlvmLibcFcntlProcessAssociatedLockTest.UseAfterClose
[       OK ] LlvmLibcFcntlProcessAssociatedLockTest.UseAfterClose (196 us)
[ RUN      ] LlvmLibcFcntlOpenFileDescriptionLockTest.GetLkRead
[       OK ] LlvmLibcFcntlOpenFileDescriptionLockTest.GetLkRead (87 us)
[ RUN      ] LlvmLibcFcntlOpenFileDescriptionLockTest.GetLkWrite
[       OK ] LlvmLibcFcntlOpenFileDescriptionLockTest.GetLkWrite (91 us)
[ RUN      ] LlvmLibcFcntlOpenFileDescriptionLockTest.UseAfterClose
=================================================================
==191364==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffd1e917019 at pc 0x5570d9f63097 bp 0x7ffd1e916910 sp 0x7ffd1e916908
READ of size 4 at 0x7ffd1e917019 thread T0
    #0 0x5570d9f63096 in __llvm_libc_20_0_0_git::internal::fcntl(int, int, void*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/__support/OSUtil/linux/fcntl.cpp:63:24
    #1 0x5570d9f64e69 in __llvm_libc_20_0_0_git::fcntl(int, int, ...) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/fcntl/linux/fcntl.cpp:27:17
    #2 0x5570d9f60113 in LibcFcntlCommonLockTests<36, 37>::UseAfterClose() /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/src/fcntl/fcntl_test.cpp:175:5
    #3 0x5570d9f5a5d4 in LlvmLibcFcntlOpenFileDescriptionLockTest_UseAfterClose::Run() /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/src/fcntl/fcntl_test.cpp:188:1
    #4 0x5570d9f6d327 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 0x5570d9fa8bd8 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 0x7f1a96e25249  (/lib/x86_64-linux-gnu/libc.so.6+0x27249) (BuildId: 6196744a316dbd57c0fd8968df1680aac482cec4)

Address 0x7ffd1e917019 is located in stack of thread T0 at offset 57 in frame
    #0 0x5570d9f5fdaf in LibcFcntlCommonLockTests<36, 37>::UseAfterClose() /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/src/fcntl/fcntl_test.cpp:167

  This frame has 8 object(s):
    [32, 56) 'TEST_FILE' (line 171) <== Memory access at offset 57 overflows this variable
    [96, 128) 'ref.tmp' (line 174)
    [160, 176) 'agg.tmp'
    [192, 193) 'ref.tmp13' (line 174)
Step 7 (libc-unit-tests) failure: libc-unit-tests (failure)
...
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcSharedMathTest.AllFloat
[       OK ] LlvmLibcSharedMathTest.AllFloat (86 us)
[ RUN      ] LlvmLibcSharedMathTest.AllDouble
[       OK ] LlvmLibcSharedMathTest.AllDouble (33 us)
[ RUN      ] LlvmLibcSharedMathTest.AllFloat128
[       OK ] LlvmLibcSharedMathTest.AllFloat128 (120 us)
Ran 3 tests.  PASS: 3  FAIL: 0
[2527/2533] Linking CXX executable libc/test/src/fcntl/libc.test.src.fcntl.fcntl_test.__build__
[2528/2533] Running unit test libc.test.src.fcntl.fcntl_test
FAILED: libc/test/src/fcntl/CMakeFiles/libc.test.src.fcntl.fcntl_test /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/libc/test/src/fcntl/CMakeFiles/libc.test.src.fcntl.fcntl_test 
cd /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/libc/test/src/fcntl && /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/libc/test/src/fcntl/libc.test.src.fcntl.fcntl_test.__build__
[==========] Running 10 tests from 1 test suite.
[ RUN      ] LlvmLibcFcntlTest.FcntlDupfd
[       OK ] LlvmLibcFcntlTest.FcntlDupfd (291 us)
[ RUN      ] LlvmLibcFcntlTest.FcntlGetFl
[       OK ] LlvmLibcFcntlTest.FcntlGetFl (72 us)
[ RUN      ] LlvmLibcFcntlTest.FcntlSetFl
[       OK ] LlvmLibcFcntlTest.FcntlSetFl (104 us)
[ RUN      ] LlvmLibcFcntlProcessAssociatedLockTest.GetLkRead
[       OK ] LlvmLibcFcntlProcessAssociatedLockTest.GetLkRead (176 us)
[ RUN      ] LlvmLibcFcntlProcessAssociatedLockTest.GetLkWrite
[       OK ] LlvmLibcFcntlProcessAssociatedLockTest.GetLkWrite (98 us)
[ RUN      ] LlvmLibcFcntlProcessAssociatedLockTest.UseAfterClose
[       OK ] LlvmLibcFcntlProcessAssociatedLockTest.UseAfterClose (196 us)
[ RUN      ] LlvmLibcFcntlOpenFileDescriptionLockTest.GetLkRead
[       OK ] LlvmLibcFcntlOpenFileDescriptionLockTest.GetLkRead (87 us)
[ RUN      ] LlvmLibcFcntlOpenFileDescriptionLockTest.GetLkWrite
[       OK ] LlvmLibcFcntlOpenFileDescriptionLockTest.GetLkWrite (91 us)
[ RUN      ] LlvmLibcFcntlOpenFileDescriptionLockTest.UseAfterClose
=================================================================
==191364==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffd1e917019 at pc 0x5570d9f63097 bp 0x7ffd1e916910 sp 0x7ffd1e916908
READ of size 4 at 0x7ffd1e917019 thread T0
    #0 0x5570d9f63096 in __llvm_libc_20_0_0_git::internal::fcntl(int, int, void*) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/__support/OSUtil/linux/fcntl.cpp:63:24
    #1 0x5570d9f64e69 in __llvm_libc_20_0_0_git::fcntl(int, int, ...) /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/src/fcntl/linux/fcntl.cpp:27:17
    #2 0x5570d9f60113 in LibcFcntlCommonLockTests<36, 37>::UseAfterClose() /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/src/fcntl/fcntl_test.cpp:175:5
    #3 0x5570d9f5a5d4 in LlvmLibcFcntlOpenFileDescriptionLockTest_UseAfterClose::Run() /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/src/fcntl/fcntl_test.cpp:188:1
    #4 0x5570d9f6d327 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 0x5570d9fa8bd8 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 0x7f1a96e25249  (/lib/x86_64-linux-gnu/libc.so.6+0x27249) (BuildId: 6196744a316dbd57c0fd8968df1680aac482cec4)

Address 0x7ffd1e917019 is located in stack of thread T0 at offset 57 in frame
    #0 0x5570d9f5fdaf in LibcFcntlCommonLockTests<36, 37>::UseAfterClose() /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-project/libc/test/src/fcntl/fcntl_test.cpp:167

  This frame has 8 object(s):
    [32, 56) 'TEST_FILE' (line 171) <== Memory access at offset 57 overflows this variable
    [96, 128) 'ref.tmp' (line 174)
    [160, 176) 'agg.tmp'
    [192, 193) 'ref.tmp13' (line 174)

jtstogel added a commit that referenced this pull request Nov 5, 2025
jtstogel added a commit that referenced this pull request Nov 5, 2025
Reverts #166252

Causing buildbot failures on `libc-x86_64-debian-dbg-asan`.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Nov 5, 2025
…l." (#166658)

Reverts llvm/llvm-project#166252

Causing buildbot failures on `libc-x86_64-debian-dbg-asan`.
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.

5 participants