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

[NFC][Sanitizer] Refine the restriction on SizeClassAllocator64::kRegionSize #86270

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

Enna1
Copy link
Contributor

@Enna1 Enna1 commented Mar 22, 2024

This patch replaces the SANITIZER_WORDSIZE / 2 with sizeof(CompactPtrT) * 8, replaces hardcoded 4 with kCompactPtrScale in assertion.

@Enna1 Enna1 marked this pull request as ready for review March 22, 2024 11:25
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 22, 2024

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

Author: Enna1 (Enna1)

Changes

This patch replaces the SANITIZER_WORDSIZE / 2 with sizeof(CompactPtrT) * 8, replaces hardcoded 4 with kCompactPtrScale in assertion.


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

1 Files Affected:

  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h (+2-1)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
index 34a64f26478fd5..6e73065d7f53c5 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
@@ -639,7 +639,8 @@ class SizeClassAllocator64 {
   static_assert(kRegionSize >= SizeClassMap::kMaxSize,
                 "Region size exceed largest size");
   // kRegionSize must be <= 2^36, see CompactPtrT.
-  COMPILER_CHECK((kRegionSize) <= (1ULL << (SANITIZER_WORDSIZE / 2 + 4)));
+  COMPILER_CHECK((kRegionSize) <=
+                 (1ULL << (sizeof(CompactPtrT) * 8 + kCompactPtrScale)));
   // Call mmap for user memory with at least this size.
   static const uptr kUserMapSize = 1 << 18;
   // Call mmap for metadata memory with at least this size.

@Enna1 Enna1 merged commit 4720e38 into main Mar 27, 2024
9 checks passed
@Enna1 Enna1 deleted the users/Enna1/sanitizer-allocator-kRegionSize-assert branch March 27, 2024 01:06
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