Skip to content

[libc] Implement process_mrelease #117851

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 9 commits into from
Nov 28, 2024
Merged

Conversation

moar55
Copy link
Contributor

@moar55 moar55 commented Nov 27, 2024

This PR implements process_mrelease.
A previous PR was merged #117503, but failed on merge due to an issue in the tests. Namely the failing tests were comparing against return type as opposed to errno. This is fixed in this PR.

@llvmbot llvmbot added the libc label Nov 27, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 27, 2024

@llvm/pr-subscribers-libc

Author: Omar Hossam (moar55)

Changes

This PR implements process_mrelease.
A previous PR was merged #117503, but failed on merge due to an issue in the tests. Namely the failing tests were comparing against return type as opposed to errno. This is fixed in this PR.


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

12 Files Affected:

  • (modified) libc/config/linux/aarch64/entrypoints.txt (+1)
  • (modified) libc/config/linux/riscv/entrypoints.txt (+1)
  • (modified) libc/config/linux/x86_64/entrypoints.txt (+1)
  • (modified) libc/include/sys/syscall.h.def (+7)
  • (modified) libc/newhdrgen/yaml/sys/mman.yaml (+7)
  • (modified) libc/spec/linux.td (+6)
  • (modified) libc/src/sys/mman/CMakeLists.txt (+6)
  • (modified) libc/src/sys/mman/linux/CMakeLists.txt (+11-1)
  • (added) libc/src/sys/mman/linux/process_mrelease.cpp (+33)
  • (added) libc/src/sys/mman/process_mrelease.h (+21)
  • (modified) libc/test/src/sys/mman/linux/CMakeLists.txt (+20)
  • (added) libc/test/src/sys/mman/linux/process_mrelease_test.cpp (+74)
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 74ca3742977a5f..08b5072499da69 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -252,6 +252,7 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.sys.mman.munlockall
     libc.src.sys.mman.munmap
     libc.src.sys.mman.remap_file_pages
+    libc.src.sys.mman.process_mrelease
     libc.src.sys.mman.posix_madvise
     libc.src.sys.mman.shm_open
     libc.src.sys.mman.shm_unlink
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 5419462d4f5b3b..4ea65f76d7948d 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -251,6 +251,7 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.sys.mman.munmap
     libc.src.sys.mman.remap_file_pages
     libc.src.sys.mman.posix_madvise
+    libc.src.sys.mman.process_mrelease
     libc.src.sys.mman.shm_open
     libc.src.sys.mman.shm_unlink
 
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 957e28bd66cc4c..d0651c06b930ad 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -252,6 +252,7 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.sys.mman.munmap
     libc.src.sys.mman.remap_file_pages
     libc.src.sys.mman.posix_madvise
+    libc.src.sys.mman.process_mrelease
     libc.src.sys.mman.shm_open
     libc.src.sys.mman.shm_unlink
 
diff --git a/libc/include/sys/syscall.h.def b/libc/include/sys/syscall.h.def
index 03c19eb0885ed6..11758ea8336ddf 100644
--- a/libc/include/sys/syscall.h.def
+++ b/libc/include/sys/syscall.h.def
@@ -2349,5 +2349,12 @@
 #define SYS_writev __NR_writev
 #endif
 
+#ifdef __NR_process_mrelease
+#define SYS_process_mrelease __NR_process_mrelease
+#endif
+
+#ifdef __NR_pidfd_open
+#define SYS_pidfd_open __NR_pidfd_open
+#endif
 
 #endif // LLVM_LIBC_SYS_SYSCALL_H
diff --git a/libc/newhdrgen/yaml/sys/mman.yaml b/libc/newhdrgen/yaml/sys/mman.yaml
index 962ca3591917f7..dd53eb60d1ec57 100644
--- a/libc/newhdrgen/yaml/sys/mman.yaml
+++ b/libc/newhdrgen/yaml/sys/mman.yaml
@@ -132,3 +132,10 @@ functions:
     return_type: int
     arguments:
       - type: const char *
+  - name: process_mrelease
+    standards:
+      - Linux
+    return_type: int
+    arguments:
+      - type: int
+      - type: unsigned int
diff --git a/libc/spec/linux.td b/libc/spec/linux.td
index 9b5dc8e30c95e4..99e0949a592dfa 100644
--- a/libc/spec/linux.td
+++ b/libc/spec/linux.td
@@ -112,6 +112,12 @@ def Linux : StandardSpec<"Linux"> {
             ArgSpec<IntType>,
             ArgSpec<SizeTType>,
             ArgSpec<IntType>,
+        FunctionSpec<
+          "process_mrelease",
+          RetValSpec<IntType>,
+          [
+            ArgSpec<IntType>,
+            ArgSpec<UnsignedIntType>
           ]
         >,
         FunctionSpec<
diff --git a/libc/src/sys/mman/CMakeLists.txt b/libc/src/sys/mman/CMakeLists.txt
index 4d4c2ad376050e..281efc0ffcdf20 100644
--- a/libc/src/sys/mman/CMakeLists.txt
+++ b/libc/src/sys/mman/CMakeLists.txt
@@ -113,3 +113,9 @@ add_entrypoint_object(
   DEPENDS
     .${LIBC_TARGET_OS}.mremap
 )
+
+add_entrypoint_object(
+  process_mrelease 
+  ALIAS 
+  DEPENDS
+    .${LIBC_TARGET_OS}.process_mrelease)
diff --git a/libc/src/sys/mman/linux/CMakeLists.txt b/libc/src/sys/mman/linux/CMakeLists.txt
index 89a0ad1527a065..aa2ca4b160181a 100644
--- a/libc/src/sys/mman/linux/CMakeLists.txt
+++ b/libc/src/sys/mman/linux/CMakeLists.txt
@@ -36,7 +36,6 @@ add_entrypoint_object(
     libc.src.__support.OSUtil.osutil
     libc.src.errno.errno
 )
-
 add_entrypoint_object(
   munmap
   SRCS
@@ -214,3 +213,14 @@ add_entrypoint_object(
     libc.src.unistd.unlink
     .shm_common
 )
+
+add_entrypoint_object(
+  process_mrelease
+  SRCS
+    process_mrelease.cpp
+  HDRS
+    ../process_mrelease.h
+  DEPENDS
+    libc.include.sys_syscall
+    libc.src.__support.OSUtil.osutil
+    libc.src.errno.errno)
diff --git a/libc/src/sys/mman/linux/process_mrelease.cpp b/libc/src/sys/mman/linux/process_mrelease.cpp
new file mode 100644
index 00000000000000..e86bbec1b1b661
--- /dev/null
+++ b/libc/src/sys/mman/linux/process_mrelease.cpp
@@ -0,0 +1,33 @@
+//===---------- Linux implementation of the mrelease function -----------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/sys/mman/process_mrelease.h"
+
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/common.h"
+
+#include "src/__support/macros/config.h"
+#include "src/errno/libc_errno.h"
+#include <linux/param.h> // For EXEC_PAGESIZE.
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(int, process_mrelease, (int pidfd, unsigned int flags)) {
+  long ret =
+      LIBC_NAMESPACE::syscall_impl<int>(SYS_process_mrelease, pidfd, flags);
+
+  if (ret < 0) {
+    libc_errno = static_cast<int>(-ret);
+    return -1;
+  }
+
+  return 0;
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/sys/mman/process_mrelease.h b/libc/src/sys/mman/process_mrelease.h
new file mode 100644
index 00000000000000..ec4a6e4768bcac
--- /dev/null
+++ b/libc/src/sys/mman/process_mrelease.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for process_mrelease function --------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===-------------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_SYS_MMAN_PROCESS_MRELEASE_H
+#define LLVM_LIBC_SRC_SYS_MMAN_PROCESS_MRELEASE_H
+
+#include "src/__support/macros/config.h"
+#include <sys/mman.h> // For size_t and off_t
+
+namespace LIBC_NAMESPACE_DECL {
+
+int process_mrelease(int pidfd, unsigned int flags);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_SYS_MMAN_PROCESS_MRELEASE_H
diff --git a/libc/test/src/sys/mman/linux/CMakeLists.txt b/libc/test/src/sys/mman/linux/CMakeLists.txt
index 44ed11aadfe8b7..6021ccd8c89a82 100644
--- a/libc/test/src/sys/mman/linux/CMakeLists.txt
+++ b/libc/test/src/sys/mman/linux/CMakeLists.txt
@@ -181,3 +181,23 @@ add_libc_unittest(
     libc.hdr.fcntl_macros
     libc.test.UnitTest.ErrnoSetterMatcher
 )
+
+add_libc_unittest(
+  process_mrelease_test
+  SUITE
+    libc_sys_mman_unittests
+  SRCS
+    process_mrelease_test.cpp
+  DEPENDS
+    libc.include.sys_mman
+    libc.include.sys_syscall
+    libc.src.errno.errno
+    libc.src.sys.mman.process_mrelease
+    libc.src.unistd.close
+    libc.src.signal.kill
+    libc.include.signal
+    libc.src.stdlib.exit
+    libc.src.__support.OSUtil.osutil
+    libc.src.__support.threads.sleep
+    libc.test.UnitTest.ErrnoSetterMatcher
+    )
diff --git a/libc/test/src/sys/mman/linux/process_mrelease_test.cpp b/libc/test/src/sys/mman/linux/process_mrelease_test.cpp
new file mode 100644
index 00000000000000..1c3c549aa9bebd
--- /dev/null
+++ b/libc/test/src/sys/mman/linux/process_mrelease_test.cpp
@@ -0,0 +1,74 @@
+//===-- Unittests for process_mrelease ------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/threads/sleep.h"
+#include "src/errno/libc_errno.h"
+#include "src/signal/kill.h"
+#include "src/stdlib/exit.h"
+#include "src/sys/mman/process_mrelease.h"
+#include "src/unistd/close.h"
+#include "src/unistd/fork.h"
+#include "test/UnitTest/ErrnoSetterMatcher.h"
+#include "test/UnitTest/LibcTest.h"
+
+#include <sys/syscall.h>
+
+using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
+
+int pidfd_open(pid_t pid, unsigned int flags) {
+  return LIBC_NAMESPACE::syscall_impl(SYS_pidfd_open, pid, flags);
+}
+
+TEST(LlvmLibcMProcessMReleaseTest, NoError) {
+  pid_t child_pid = fork();
+  EXPECT_GE(child_pid, 0);
+
+  if (child_pid == 0) {
+    // Child process: wait a bit then exit gracefully.
+    LIBC_NAMESPACE::sleep_briefly();
+    LIBC_NAMESPACE::exit(0);
+  } else {
+    // Parent process: wait a bit and then kill the child.
+    // Give child process some time to start.
+    LIBC_NAMESPACE::sleep_briefly();
+    int pidfd = pidfd_open(child_pid, 0);
+    EXPECT_GE(pidfd, 0);
+
+    // Send SIGKILL to child process
+    LIBC_NAMESPACE::kill(child_pid, SIGKILL);
+
+    EXPECT_THAT(LIBC_NAMESPACE::process_mrelease(pidfd, 0), Succeeds());
+
+    LIBC_NAMESPACE::close(pidfd);
+  }
+}
+
+TEST(LlvmLibcMProcessMReleaseTest, ErrorNotKilled) {
+  pid_t child_pid = fork();
+  EXPECT_GE(child_pid, 0);
+
+  if (child_pid == 0) {
+    // Child process: wait a bit then exit gracefully.
+    LIBC_NAMESPACE::sleep_briefly();
+    LIBC_NAMESPACE::exit(0);
+  } else {
+    // Give child process some time to start.
+    LIBC_NAMESPACE::sleep_briefly();
+    int pidfd = pidfd_open(child_pid, 0);
+    EXPECT_GE(pidfd, 0);
+
+    EXPECT_THAT(LIBC_NAMESPACE::process_mrelease(pidfd, 0), Fails(EINVAL));
+
+    LIBC_NAMESPACE::close(pidfd);
+  }
+}
+
+TEST(LlvmLibcMProcessMReleaseTest, ErrorNonExistingPidfd) {
+  EXPECT_THAT(LIBC_NAMESPACE::process_mrelease(-1, 0), Fails(EBADF));
+}

Copy link

github-actions bot commented Nov 27, 2024

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

@moar55
Copy link
Contributor Author

moar55 commented Nov 27, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:

git-clang-format --diff b0bdbf4288a664179024eead871a5e7b7fae6dda f3a87b4246bf6578794b95253efee96932a5f447 --extensions h,cpp -- libc/src/sys/mman/linux/process_mrelease.cpp libc/src/sys/mman/process_mrelease.h libc/test/src/sys/mman/linux/process_mrelease_test.cpp

View the diff from clang-format here.

diff --git a/libc/src/sys/mman/process_mrelease.h b/libc/src/sys/mman/process_mrelease.h
index ec4a6e4768..45c896eb13 100644
--- a/libc/src/sys/mman/process_mrelease.h
+++ b/libc/src/sys/mman/process_mrelease.h
@@ -1,4 +1,5 @@
-//===-- Implementation header for process_mrelease function --------*- C++ -*-===//
+//===-- Implementation header for process_mrelease function --------*- C++
+//-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

That doesn't look like the right format 🤔

@SchrodingerZhu
Copy link
Contributor

@moar55 it should be the case that the header is too long. You can shrink the license header by removing some -

@moar55
Copy link
Contributor Author

moar55 commented Nov 27, 2024

@SchrodingerZhu hey it passes now, can you double-check all is good :)

Copy link
Contributor

@SchrodingerZhu SchrodingerZhu left a comment

Choose a reason for hiding this comment

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

LGTM with a small nit.

@SchrodingerZhu SchrodingerZhu merged commit d2b482b into llvm:main Nov 28, 2024
7 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 28, 2024

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

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

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)
...
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_POSIX_REGEX -- success
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Performing Test HAVE_PTHREAD_AFFINITY -- failed to compile
-- Configuring done
-- Generating done
-- Build files have been written to: /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/build
@@@BUILD_STEP build libc@@@
Running: ninja libc
[1/2] Building CXX object projects/libc/src/sys/mman/linux/CMakeFiles/libc.src.sys.mman.linux.process_mrelease.dir/process_mrelease.cpp.o
FAILED: projects/libc/src/sys/mman/linux/CMakeFiles/libc.src.sys.mman.linux.process_mrelease.dir/process_mrelease.cpp.o 
/usr/bin/clang++ -DLIBC_NAMESPACE=__llvm_libc_20_0_0_git -D_DEBUG -Iprojects/libc/src/sys/mman/linux -I/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/sys/mman/linux -I/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc -isystem projects/libc/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -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 -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 -std=c++17 -MD -MT projects/libc/src/sys/mman/linux/CMakeFiles/libc.src.sys.mman.linux.process_mrelease.dir/process_mrelease.cpp.o -MF projects/libc/src/sys/mman/linux/CMakeFiles/libc.src.sys.mman.linux.process_mrelease.dir/process_mrelease.cpp.o.d -o projects/libc/src/sys/mman/linux/CMakeFiles/libc.src.sys.mman.linux.process_mrelease.dir/process_mrelease.cpp.o -c /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/sys/mman/linux/process_mrelease.cpp
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/sys/mman/linux/process_mrelease.cpp:23:41: error: use of undeclared identifier 'SYS_process_mrelease'
      LIBC_NAMESPACE::syscall_impl<int>(SYS_process_mrelease, pidfd, flags);
                                        ^
1 error generated.
ninja: build stopped: subcommand failed.
['ninja', 'libc'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File "../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 162, in step
    yield
  File "../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 124, in main
    run_command(['ninja', 'libc'])
  File "../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 177, in run_command
    util.report_run_cmd(cmd, cwd=directory)
  File "/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-zorg/zorg/buildbot/builders/annotated/util.py", line 49, in report_run_cmd
    subprocess.check_call(cmd, shell=shell, *args, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 190, in check_call
    raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '['ninja', 'libc']' returned non-zero exit status 1
@@@STEP_FAILURE@@@
@@@BUILD_STEP libc-unit-tests@@@
Running: ninja libc-unit-tests
[1/984] Running unit test libc.test.src.math.ldexpf_test.__unit__
[==========] Running 6 tests from 1 test suite.
[ RUN      ] LlvmLibcLdExpTest.SpecialNumbers
[       OK ] LlvmLibcLdExpTest.SpecialNumbers (5 us)
[ RUN      ] LlvmLibcLdExpTest.PowersOfTwo
[       OK ] LlvmLibcLdExpTest.PowersOfTwo (7 us)
[ RUN      ] LlvmLibcLdExpTest.OverFlow
[       OK ] LlvmLibcLdExpTest.OverFlow (29 us)
[ RUN      ] LlvmLibcLdExpTest.UnderflowToZeroOnNormal
[       OK ] LlvmLibcLdExpTest.UnderflowToZeroOnNormal (2 us)
[ RUN      ] LlvmLibcLdExpTest.UnderflowToZeroOnSubnormal
[       OK ] LlvmLibcLdExpTest.UnderflowToZeroOnSubnormal (2 us)
[ RUN      ] LlvmLibcLdExpTest.NormalOperation
[       OK ] LlvmLibcLdExpTest.NormalOperation (72 us)
Ran 6 tests.  PASS: 6  FAIL: 0

@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 28, 2024

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

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

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)
...
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_POSIX_REGEX -- success
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Performing Test HAVE_PTHREAD_AFFINITY -- failed to compile
-- Configuring done
-- Generating done
-- Build files have been written to: /home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/build
@@@BUILD_STEP build libc@@@
Running: ninja libc
[1/2] Building CXX object projects/libc/src/sys/mman/linux/CMakeFiles/libc.src.sys.mman.linux.process_mrelease.dir/process_mrelease.cpp.o
FAILED: projects/libc/src/sys/mman/linux/CMakeFiles/libc.src.sys.mman.linux.process_mrelease.dir/process_mrelease.cpp.o 
/usr/bin/clang++ -DLIBC_NAMESPACE=__llvm_libc_18_0_0_git -D_DEBUG -I/home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/build/projects/libc/src/sys/mman/linux -I/home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/llvm-project/libc/src/sys/mman/linux -I/home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/llvm-project/libc -isystem /home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/build/projects/libc/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -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 -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 -std=c++17 -MD -MT projects/libc/src/sys/mman/linux/CMakeFiles/libc.src.sys.mman.linux.process_mrelease.dir/process_mrelease.cpp.o -MF projects/libc/src/sys/mman/linux/CMakeFiles/libc.src.sys.mman.linux.process_mrelease.dir/process_mrelease.cpp.o.d -o projects/libc/src/sys/mman/linux/CMakeFiles/libc.src.sys.mman.linux.process_mrelease.dir/process_mrelease.cpp.o -c /home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/llvm-project/libc/src/sys/mman/linux/process_mrelease.cpp
/home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/llvm-project/libc/src/sys/mman/linux/process_mrelease.cpp:23:41: error: use of undeclared identifier 'SYS_process_mrelease'
      LIBC_NAMESPACE::syscall_impl<int>(SYS_process_mrelease, pidfd, flags);
                                        ^
1 error generated.
ninja: build stopped: subcommand failed.
['ninja', 'libc'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File "/home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 162, in step
    yield
  File "/home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 124, in main
    run_command(['ninja', 'libc'])
  File "/home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 177, in run_command
    util.report_run_cmd(cmd, cwd=directory)
  File "/home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/llvm-zorg/zorg/buildbot/builders/annotated/util.py", line 49, in report_run_cmd
    subprocess.check_call(cmd, shell=shell, *args, **kwargs)
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ninja', 'libc']' returned non-zero exit status 1.
@@@STEP_FAILURE@@@
@@@BUILD_STEP libc-unit-tests@@@
Running: ninja libc-unit-tests

@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 28, 2024

LLVM Buildbot has detected a new failure on builder libc-riscv32-qemu-yocto-fullbuild-dbg running on rv32gc-qemu-system while building libc at step 4 "annotate".

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

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)
...
Ran 2 tests.  PASS: 2  FAIL: 0
[3769/3897] Running unit test libc.test.src.sys.mman.linux.posix_madvise_test
sh: line 1: /timer.26955: Permission denied
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcPosixMadviseTest.NoError
[       OK ] LlvmLibcPosixMadviseTest.NoError (1 ms)
[ RUN      ] LlvmLibcPosixMadviseTest.Error_BadPtr
[       OK ] LlvmLibcPosixMadviseTest.Error_BadPtr (105 us)
Ran 2 tests.  PASS: 2  FAIL: 0
[3770/3897] Running unit test libc.test.src.sys.mman.linux.process_mrelease_test
FAILED: projects/libc/test/src/sys/mman/linux/CMakeFiles/libc.test.src.sys.mman.linux.process_mrelease_test /home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/build/projects/libc/test/src/sys/mman/linux/CMakeFiles/libc.test.src.sys.mman.linux.process_mrelease_test 
cd /home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/build/projects/libc/test/src/sys/mman/linux && /home/libcrv32buildbot/cross.sh /home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/build/projects/libc/test/src/sys/mman/linux/libc.test.src.sys.mman.linux.process_mrelease_test.__build__
sh: line 1: /timer.26968: Permission denied
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcProcessMReleaseTest.NoError
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/src/sys/mman/linux/process_mrelease_test.cpp:46: FAILURE
Failed to match LIBC_NAMESPACE::process_mrelease(pidfd, 0) against Succeeds().
Expected return value to be equal to 0 but got -1.
Expected errno to be equal to "Success" but got "No such process".
[  FAILED  ] LlvmLibcProcessMReleaseTest.NoError
[ RUN      ] LlvmLibcProcessMReleaseTest.ErrorNotKilled
[       OK ] LlvmLibcProcessMReleaseTest.ErrorNotKilled (845 us)
[ RUN      ] LlvmLibcProcessMReleaseTest.ErrorNonExistingPidfd
[       OK ] LlvmLibcProcessMReleaseTest.ErrorNonExistingPidfd (88 us)
Ran 3 tests.  PASS: 2  FAIL: 1
[3771/3897] Running unit test libc.test.src.sys.mman.linux.mlock_test
sh: line 1: /timer.26962: Permission denied
[==========] Running 5 tests from 1 test suite.
[ RUN      ] LlvmLibcMlockTest.UnMappedMemory
[       OK ] LlvmLibcMlockTest.UnMappedMemory (587 us)
[ RUN      ] LlvmLibcMlockTest.Overflow
[       OK ] LlvmLibcMlockTest.Overflow (2 ms)
[ RUN      ] LlvmLibcMlockTest.MLock2
[       OK ] LlvmLibcMlockTest.MLock2 (1 ms)
[ RUN      ] LlvmLibcMlockTest.InvalidFlag
[       OK ] LlvmLibcMlockTest.InvalidFlag (490 us)
[ RUN      ] LlvmLibcMlockTest.MLockAll
[       OK ] LlvmLibcMlockTest.MLockAll (33 ms)
Ran 5 tests.  PASS: 5  FAIL: 0
[3772/3897] Running unit test libc.test.src.inttypes.strtoumax_test.__unit__
sh: line 1: /timer.26799: Permission denied
[==========] Running 7 tests from 1 test suite.
[ RUN      ] LlvmLibcStrtoumaxTest.InvalidBase
[       OK ] LlvmLibcStrtoumaxTest.InvalidBase (579 us)
[ RUN      ] LlvmLibcStrtoumaxTest.CleanBaseTenDecode
[       OK ] LlvmLibcStrtoumaxTest.CleanBaseTenDecode (1 ms)
[ RUN      ] LlvmLibcStrtoumaxTest.MessyBaseTenDecode
[       OK ] LlvmLibcStrtoumaxTest.MessyBaseTenDecode (1 ms)
[ RUN      ] LlvmLibcStrtoumaxTest.DecodeInOtherBases
Step 8 (libc-unit-tests) failure: libc-unit-tests (failure)
...
Ran 2 tests.  PASS: 2  FAIL: 0
[3769/3897] Running unit test libc.test.src.sys.mman.linux.posix_madvise_test
sh: line 1: /timer.26955: Permission denied
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcPosixMadviseTest.NoError
[       OK ] LlvmLibcPosixMadviseTest.NoError (1 ms)
[ RUN      ] LlvmLibcPosixMadviseTest.Error_BadPtr
[       OK ] LlvmLibcPosixMadviseTest.Error_BadPtr (105 us)
Ran 2 tests.  PASS: 2  FAIL: 0
[3770/3897] Running unit test libc.test.src.sys.mman.linux.process_mrelease_test
FAILED: projects/libc/test/src/sys/mman/linux/CMakeFiles/libc.test.src.sys.mman.linux.process_mrelease_test /home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/build/projects/libc/test/src/sys/mman/linux/CMakeFiles/libc.test.src.sys.mman.linux.process_mrelease_test 
cd /home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/build/projects/libc/test/src/sys/mman/linux && /home/libcrv32buildbot/cross.sh /home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/build/projects/libc/test/src/sys/mman/linux/libc.test.src.sys.mman.linux.process_mrelease_test.__build__
sh: line 1: /timer.26968: Permission denied
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcProcessMReleaseTest.NoError
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/src/sys/mman/linux/process_mrelease_test.cpp:46: FAILURE
Failed to match LIBC_NAMESPACE::process_mrelease(pidfd, 0) against Succeeds().
Expected return value to be equal to 0 but got -1.
Expected errno to be equal to "Success" but got "No such process".
[  FAILED  ] LlvmLibcProcessMReleaseTest.NoError
[ RUN      ] LlvmLibcProcessMReleaseTest.ErrorNotKilled
[       OK ] LlvmLibcProcessMReleaseTest.ErrorNotKilled (845 us)
[ RUN      ] LlvmLibcProcessMReleaseTest.ErrorNonExistingPidfd
[       OK ] LlvmLibcProcessMReleaseTest.ErrorNonExistingPidfd (88 us)
Ran 3 tests.  PASS: 2  FAIL: 1
[3771/3897] Running unit test libc.test.src.sys.mman.linux.mlock_test
sh: line 1: /timer.26962: Permission denied
[==========] Running 5 tests from 1 test suite.
[ RUN      ] LlvmLibcMlockTest.UnMappedMemory
[       OK ] LlvmLibcMlockTest.UnMappedMemory (587 us)
[ RUN      ] LlvmLibcMlockTest.Overflow
[       OK ] LlvmLibcMlockTest.Overflow (2 ms)
[ RUN      ] LlvmLibcMlockTest.MLock2
[       OK ] LlvmLibcMlockTest.MLock2 (1 ms)
[ RUN      ] LlvmLibcMlockTest.InvalidFlag
[       OK ] LlvmLibcMlockTest.InvalidFlag (490 us)
[ RUN      ] LlvmLibcMlockTest.MLockAll
[       OK ] LlvmLibcMlockTest.MLockAll (33 ms)
Ran 5 tests.  PASS: 5  FAIL: 0
[3772/3897] Running unit test libc.test.src.inttypes.strtoumax_test.__unit__
sh: line 1: /timer.26799: Permission denied
[==========] Running 7 tests from 1 test suite.
[ RUN      ] LlvmLibcStrtoumaxTest.InvalidBase
[       OK ] LlvmLibcStrtoumaxTest.InvalidBase (579 us)
[ RUN      ] LlvmLibcStrtoumaxTest.CleanBaseTenDecode
[       OK ] LlvmLibcStrtoumaxTest.CleanBaseTenDecode (1 ms)
[ RUN      ] LlvmLibcStrtoumaxTest.MessyBaseTenDecode
[       OK ] LlvmLibcStrtoumaxTest.MessyBaseTenDecode (1 ms)
[ RUN      ] LlvmLibcStrtoumaxTest.DecodeInOtherBases

@nickdesaulniers
Copy link
Member

The buildbots have been super flaky lately (since yesterday). Is this PR to blame? It looks like @SchrodingerZhu put some patches on top (they should link to this PR in their commit messages), but the bots seem to be timing out occasionally. If this patch is problematic, it should get backed out. Most of us are on holiday this week for Thanksgiving in the US; will investigate this more next week.

SchrodingerZhu added a commit to SchrodingerZhu/llvm-project that referenced this pull request Dec 4, 2024
SchrodingerZhu added a commit to SchrodingerZhu/llvm-project that referenced this pull request Dec 5, 2024
moar55 added a commit to moar55/llvm-project that referenced this pull request Dec 8, 2024
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