forked from OSchip/llvm-project
[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
This commit is contained in:
parent
9f93f2bfbd
commit
6727832c32
|
@ -130,10 +130,6 @@ TEST(ScudoWrappersCppTest, ThreadedNew) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !SCUDO_FUCHSIA
|
#if !SCUDO_FUCHSIA
|
||||||
// TODO(kostyak): for me, this test fails in a specific configuration when ran
|
|
||||||
// by itself with some Scudo or GWP-ASan violation. Other people
|
|
||||||
// can't seem to reproduce the failure. Consider skipping this in
|
|
||||||
// the event it fails on the upstream bots.
|
|
||||||
TEST(ScudoWrappersCppTest, AllocAfterFork) {
|
TEST(ScudoWrappersCppTest, AllocAfterFork) {
|
||||||
std::atomic_bool Stop;
|
std::atomic_bool Stop;
|
||||||
|
|
||||||
|
@ -142,7 +138,7 @@ TEST(ScudoWrappersCppTest, AllocAfterFork) {
|
||||||
for (size_t N = 0; N < 5; N++) {
|
for (size_t N = 0; N < 5; N++) {
|
||||||
std::thread *T = new std::thread([&Stop] {
|
std::thread *T = new std::thread([&Stop] {
|
||||||
while (!Stop) {
|
while (!Stop) {
|
||||||
for (size_t SizeLog = 3; SizeLog <= 21; SizeLog++) {
|
for (size_t SizeLog = 3; SizeLog <= 20; SizeLog++) {
|
||||||
char *P = new char[1UL << SizeLog];
|
char *P = new char[1UL << SizeLog];
|
||||||
EXPECT_NE(P, nullptr);
|
EXPECT_NE(P, nullptr);
|
||||||
// Make sure this value is not optimized away.
|
// Make sure this value is not optimized away.
|
||||||
|
@ -155,10 +151,10 @@ TEST(ScudoWrappersCppTest, AllocAfterFork) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a thread to fork and allocate.
|
// Create a thread to fork and allocate.
|
||||||
for (size_t N = 0; N < 100; N++) {
|
for (size_t N = 0; N < 50; N++) {
|
||||||
pid_t Pid;
|
pid_t Pid;
|
||||||
if ((Pid = fork()) == 0) {
|
if ((Pid = fork()) == 0) {
|
||||||
for (size_t SizeLog = 3; SizeLog <= 21; SizeLog++) {
|
for (size_t SizeLog = 3; SizeLog <= 20; SizeLog++) {
|
||||||
char *P = new char[1UL << SizeLog];
|
char *P = new char[1UL << SizeLog];
|
||||||
EXPECT_NE(P, nullptr);
|
EXPECT_NE(P, nullptr);
|
||||||
// Make sure this value is not optimized away.
|
// Make sure this value is not optimized away.
|
||||||
|
|
Loading…
Reference in New Issue