[compiler-rt] [msan] Increase kNumStackOriginDescrs constant (PR #92838)

via llvm-commits llvm-commits at lists.llvm.org
Mon May 20 17:00:27 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

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

Author: Thurston Dang (thurstond)

<details>
<summary>Changes</summary>

This increases the constant size of kNumStackOriginDescrs to 64M (1GB of BSS across two arrays), which ought to be enough for anybody.

This is the easier alternative suggested by eugenis@ in https://github.com/llvm/llvm-project/pull/92826.

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


1 Files Affected:

- (modified) compiler-rt/lib/msan/msan.cpp (+7-1) 


``````````diff
diff --git a/compiler-rt/lib/msan/msan.cpp b/compiler-rt/lib/msan/msan.cpp
index a2fc27de1901b..8bef6812f21c2 100644
--- a/compiler-rt/lib/msan/msan.cpp
+++ b/compiler-rt/lib/msan/msan.cpp
@@ -100,7 +100,13 @@ int msan_report_count = 0;
 
 // Array of stack origins.
 // FIXME: make it resizable.
-static const uptr kNumStackOriginDescrs = 1024 * 1024;
+// Although BSS memory doesn't cost anything until used, it is limited to 2GB
+// in some configurations (e.g., relocation R_X86_64_PC32 out of range:
+// 8600110908 is not in [-2147483648, 2147483647]; references section '.bss')
+// hence kNumStackOriginDescrs is limited to roughly 2GB / sizeof(uptr) / 2
+// == 128M per array (StackOriginDescr, StackOriginPC). We set it at 64M each
+// in case other parts of MSan want more BSS space in the future.
+static const uptr kNumStackOriginDescrs = 64 * 1024 * 1024;
 static const char *StackOriginDescr[kNumStackOriginDescrs];
 static uptr StackOriginPC[kNumStackOriginDescrs];
 static atomic_uint32_t NumStackOriginDescrs;

``````````

</details>


https://github.com/llvm/llvm-project/pull/92838


More information about the llvm-commits mailing list