[compiler-rt] 7ceb74f - [compiler-rt] fix BSD procmaps stack frame size limit warning. (#82887)

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 29 17:25:58 PST 2024


Author: David CARLIER
Date: 2024-03-01T01:25:54Z
New Revision: 7ceb74f5b74fa4a0b68ad911afd3cad945f640a3

URL: https://github.com/llvm/llvm-project/commit/7ceb74f5b74fa4a0b68ad911afd3cad945f640a3
DIFF: https://github.com/llvm/llvm-project/commit/7ceb74f5b74fa4a0b68ad911afd3cad945f640a3.diff

LOG: [compiler-rt] fix BSD procmaps stack frame size limit warning. (#82887)

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp
index dcfd94fe3225cd..7c2d8e6f173131 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp
@@ -30,17 +30,17 @@ namespace __sanitizer {
 
 #if SANITIZER_FREEBSD
 void GetMemoryProfile(fill_profile_f cb, uptr *stats) {
-  const int Mib[] = {
-    CTL_KERN,
-    KERN_PROC,
-    KERN_PROC_PID,
-    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);
+  const int Mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()};
+
+  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
 


        


More information about the llvm-commits mailing list