[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:24:58 PDT 2026
https://github.com/Himadhith created https://github.com/llvm/llvm-project/pull/188787
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.
>From 33a2d89008ba12472f9ebd52ca6fe4ba0079e32f Mon Sep 17 00:00:00 2001
From: himadhith <himadhith.v at ibm.com>
Date: Thu, 26 Mar 2026 14:01:12 -0400
Subject: [PATCH] [libc++][AIX] Fix force_thread_creation_failure by using
RLIMIT_THREADS
---
.../futures/futures.async/thread_create_failure.pass.cpp | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
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);
More information about the libcxx-commits
mailing list