[compiler-rt] [compiler-rt] fix BSD procmaps stack size limit on build due to the k… (PR #82887)

via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 24 07:39:47 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

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

Author: David CARLIER (devnexen)

<details>
<summary>Changes</summary>

…info_proc type.

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


1 Files Affected:

- (modified) compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp (+7-4) 


``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp
index dcfd94fe3225cd..3649bfd1b25b12 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp
@@ -37,10 +37,13 @@ void GetMemoryProfile(fill_profile_f cb, uptr *stats) {
     getpid()
   }; 
 
-  struct kinfo_proc InfoProc;
-  uptr Len = sizeof(InfoProc);
-  CHECK_EQ(internal_sysctl(Mib, ARRAY_SIZE(Mib), nullptr, (uptr *)&InfoProc, &Len, 0), 0);
-  cb(0, InfoProc.ki_rssize * GetPageSizeCached(), false, stats);
+  struct kinfo_proc *InfoProc;
+  uptr Len = sizeof(*InfoProc);
+  uptr Size = Len;
+  InfoProc = (struct kinfo_proc *)MmapOrDie(Size, "GetMemoryProfile()");
+  CHECK_EQ(internal_sysctl(Mib, ARRAY_SIZE(Mib), nullptr, (uptr *)InfoProc, &Len, 0), 0);
+  cb(0, InfoProc->ki_rssize * GetPageSizeCached(), false, stats);
+  UnmapOrDie(InfoProc, Size, true);
 }
 #endif
 

``````````

</details>


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


More information about the llvm-commits mailing list