Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[scudo] Test secondary cache options only if enabled #95872

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

Caslyn
Copy link
Contributor

@Caslyn Caslyn commented Jun 18, 2024

Configs that use MapAllocatorNoCache for its secondary cache will return false if setOption is called with some specific options, and this breaks with the SecondaryOptions test.

This change will gate testing all setOption expectations for cache options only if the allocator cache is enabled. This will unblock github.com/llvm/llvm-project/pull/95595 from merging into Fuchsia.

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 18, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Caslyn Tonelli (Caslyn)

Changes

Configs that use MapAllocatorNoCache for its secondary cache will return false if setOption is called with some specific options, and this breaks with the SecondaryOptions test.

This change will gate testing all setOption expectations for cache options only if the allocator cache is enabled. This will unblock github.com//pull/95595 from merging into Fuchsia.


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

1 Files Affected:

  • (modified) compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp (+6-5)
diff --git a/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp b/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp
index af69313214ea6..e74930148f25e 100644
--- a/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp
@@ -191,12 +191,13 @@ TEST_F(MapAllocatorTest, SecondaryIterate) {
 }
 
 TEST_F(MapAllocatorTest, SecondaryOptions) {
-  // Attempt to set a maximum number of entries higher than the array size.
-  EXPECT_TRUE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 4096U));
-
-  // Attempt to set an invalid (negative) number of entries
-  EXPECT_FALSE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, -1));
+  // Test options that are only meaningful if the secondary cache is enabled.
   if (Allocator->canCache(0U)) {
+    // Attempt to set a maximum number of entries higher than the array size.
+    EXPECT_TRUE(
+        Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 4096U));
+    // Attempt to set an invalid (negative) number of entries
+    EXPECT_FALSE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, -1));
     // Various valid combinations.
     EXPECT_TRUE(Allocator->setOption(scudo::Option::MaxCacheEntriesCount, 4U));
     EXPECT_TRUE(

@Caslyn Caslyn requested a review from fabio-d June 18, 2024 00:42
@ChiaHungDuan
Copy link
Contributor

I think the fix is legit but the test is specific to DefaultConfig , thus I'm wondering how is this failed on Fuchsia?

@fabio-d
Copy link
Contributor

fabio-d commented Jun 18, 2024

I think the fix is legit but the test is specific to DefaultConfig , thus I'm wondering how is this failed on Fuchsia?

Because Fuchsia overrides it: link, link and link.

@Caslyn Caslyn merged commit 6f13f0b into llvm:main Jun 18, 2024
10 checks passed
@Caslyn Caslyn deleted the secondary-test branch June 18, 2024 17:28
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
Configs that use `MapAllocatorNoCache` for its secondary cache will
return `false` if `setOption` is called with some [specific
options](https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/scudo/standalone/secondary.h#L104),
and this breaks with the `SecondaryOptions` test.

This change will gate testing all `setOption` expectations for cache
options only if the allocator cache is enabled. This will unblock
[github.com/llvm/pull/95595
](llvm#95595) from merging into
Fuchsia.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants