[libcxx-commits] [libcxx] [libc++][AIX] Fix force_thread_creation_failure by using RLIMIT_THREADS (PR #188787)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Mar 26 09:25:38 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Himadhith

<details>
<summary>Changes</summary>

This patch fixes the test `force_thread_creation_failure.cpp` on AIX by using platform specific `RLIMIT_THREADS` which helps in restricting the thread creation as `RLIMIT_NPROC` on AIX restricts processes and not threads.

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


1 Files Affected:

- (modified) libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp (+7-2) 


``````````diff
diff --git a/libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp b/libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp
index 70009589e985b..ebc121984d061 100644
--- a/libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp
@@ -17,7 +17,7 @@
 // UNSUPPORTED: windows
 
 // AIX, macOS and FreeBSD seem to limit the number of processes, not threads via RLIMIT_NPROC
-// XFAIL: target={{.+}}-aix{{.*}}
+// But there is RLIMIT_THREADS in AIX which can be used here to limit the threads.
 // XFAIL: target={{.+}}-apple-{{.*}}
 // XFAIL: freebsd
 
@@ -33,7 +33,12 @@
 
 #if __has_include(<sys/resource.h>)
 #  include <sys/resource.h>
-#  ifdef RLIMIT_NPROC
+#  if defined(_AIX) && defined(RLIMIT_THREADS)
+void force_thread_creation_failure() {
+  rlimit lim = {1, 1};
+  assert(setrlimit(RLIMIT_THREADS, &lim) == 0);
+}
+#  elif RLIMIT_NPROC
 void force_thread_creation_failure() {
   rlimit lim = {1, 1};
   assert(setrlimit(RLIMIT_NPROC, &lim) == 0);

``````````

</details>


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


More information about the libcxx-commits mailing list