[compiler-rt] [compiler-rt] fix BSD procmaps stack size limit on build due to the k… (PR #82887)
David CARLIER via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 26 09:23:06 PST 2024
https://github.com/devnexen updated https://github.com/llvm/llvm-project/pull/82887
>From eb459b6a714b26364c082a9ca93e626960b6ab87 Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen at gmail.com>
Date: Sat, 24 Feb 2024 15:37:09 +0000
Subject: [PATCH] [compiler-rt] fix BSD procmaps stack size limit on build due
to the kinfo_proc type.
---
.../sanitizer_common/sanitizer_procmaps_bsd.cpp | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp
index dcfd94fe3225cd..72b753b841a2a9 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp
@@ -35,12 +35,17 @@ void GetMemoryProfile(fill_profile_f cb, uptr *stats) {
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);
+ 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