Skip to content

Commit 6727832

Browse files
author
Kostya Kortchinsky
committed
[scudo] Reduce the scope of AllocAfterFork
`ScudoWrappersCppTest.AllocAfterFork` was failing obscurely sometimes. Someone pointed us to Linux's `vm.max_map_count` that can be significantly lower on some machines than others. It turned out that on a machine with that setting set to 65530, some `ENOMEM` errors would occur with `mmap` & `mprotect` during that specific test. Reducing the number of times we fork, and the maximum size allocated during that test makes it pass on those machines. Differential Revision: https://reviews.llvm.org/D111342
1 parent 9f93f2b commit 6727832

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

compiler-rt/lib/scudo/standalone/tests/wrappers_cpp_test.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,6 @@ TEST(ScudoWrappersCppTest, ThreadedNew) {
130130
}
131131

132132
#if !SCUDO_FUCHSIA
133-
// TODO(kostyak): for me, this test fails in a specific configuration when ran
134-
// by itself with some Scudo or GWP-ASan violation. Other people
135-
// can't seem to reproduce the failure. Consider skipping this in
136-
// the event it fails on the upstream bots.
137133
TEST(ScudoWrappersCppTest, AllocAfterFork) {
138134
std::atomic_bool Stop;
139135

@@ -142,7 +138,7 @@ TEST(ScudoWrappersCppTest, AllocAfterFork) {
142138
for (size_t N = 0; N < 5; N++) {
143139
std::thread *T = new std::thread([&Stop] {
144140
while (!Stop) {
145-
for (size_t SizeLog = 3; SizeLog <= 21; SizeLog++) {
141+
for (size_t SizeLog = 3; SizeLog <= 20; SizeLog++) {
146142
char *P = new char[1UL << SizeLog];
147143
EXPECT_NE(P, nullptr);
148144
// Make sure this value is not optimized away.
@@ -155,10 +151,10 @@ TEST(ScudoWrappersCppTest, AllocAfterFork) {
155151
}
156152

157153
// Create a thread to fork and allocate.
158-
for (size_t N = 0; N < 100; N++) {
154+
for (size_t N = 0; N < 50; N++) {
159155
pid_t Pid;
160156
if ((Pid = fork()) == 0) {
161-
for (size_t SizeLog = 3; SizeLog <= 21; SizeLog++) {
157+
for (size_t SizeLog = 3; SizeLog <= 20; SizeLog++) {
162158
char *P = new char[1UL << SizeLog];
163159
EXPECT_NE(P, nullptr);
164160
// Make sure this value is not optimized away.

0 commit comments

Comments
 (0)