[compiler-rt] [scudo] Clean up string handling (PR #86364)
Amy Kwan via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 27 11:29:04 PDT 2024
================
@@ -123,3 +127,31 @@ TEST(ScudoStringsTest, Padding) {
testAgainstLibc<int>("%03d - %03d", 12, 1234);
testAgainstLibc<int>("%03d - %03d", -12, -1234);
}
+
+#if defined(__linux__)
+#include <sys/resource.h>
+
+TEST(ScudoStringsTest, CapacityIncreaseFails) {
+ scudo::ScopedString Str;
+
+ rlimit Limit = {};
+ EXPECT_EQ(0, getrlimit(RLIMIT_AS, &Limit));
+ rlimit EmptyLimit = {.rlim_max = Limit.rlim_max};
----------------
amy-kwan wrote:
Applying this change locally:
```
diff --git a/compiler-rt/lib/scudo/standalone/tests/strings_test.cpp b/compiler-rt/lib/scudo/standalone/tests/strings_test.cpp
index e068c48fc97c..d31ca26d53a1 100644
--- a/compiler-rt/lib/scudo/standalone/tests/strings_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/strings_test.cpp
@@ -136,7 +136,7 @@ TEST(ScudoStringsTest, CapacityIncreaseFails) {
rlimit Limit = {};
EXPECT_EQ(0, getrlimit(RLIMIT_AS, &Limit));
- rlimit EmptyLimit = {.rlim_max = Limit.rlim_max};
+ rlimit EmptyLimit = {.rlim_cur = 0, .rlim_max = Limit.rlim_max};
EXPECT_EQ(0, setrlimit(RLIMIT_AS, &EmptyLimit));
// Test requires that the default length is at least 6 characters.
diff --git a/compiler-rt/lib/scudo/standalone/tests/vector_test.cpp b/compiler-rt/lib/scudo/standalone/tests/vector_test.cpp
index b7678678d8a2..add62c5a42a3 100644
--- a/compiler-rt/lib/scudo/standalone/tests/vector_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/vector_test.cpp
@@ -55,7 +55,7 @@ TEST(ScudoVectorTest, ReallocateFails) {
rlimit Limit = {};
EXPECT_EQ(0, getrlimit(RLIMIT_AS, &Limit));
- rlimit EmptyLimit = {.rlim_max = Limit.rlim_max};
+ rlimit EmptyLimit = {.rlim_cur = 0, .rlim_max = Limit.rlim_max};
EXPECT_EQ(0, setrlimit(RLIMIT_AS, &EmptyLimit));
V.resize(capacity);
```
Appears to resolve the issue.
https://github.com/llvm/llvm-project/pull/86364
More information about the llvm-commits
mailing list