Skip to content

Commit 7ceb74f

Browse files
authored
[compiler-rt] fix BSD procmaps stack frame size limit warning. (#82887)
1 parent 9a12b0a commit 7ceb74f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ namespace __sanitizer {
3030

3131
#if SANITIZER_FREEBSD
3232
void GetMemoryProfile(fill_profile_f cb, uptr *stats) {
33-
const int Mib[] = {
34-
CTL_KERN,
35-
KERN_PROC,
36-
KERN_PROC_PID,
37-
getpid()
38-
};
39-
40-
struct kinfo_proc InfoProc;
41-
uptr Len = sizeof(InfoProc);
42-
CHECK_EQ(internal_sysctl(Mib, ARRAY_SIZE(Mib), nullptr, (uptr *)&InfoProc, &Len, 0), 0);
43-
cb(0, InfoProc.ki_rssize * GetPageSizeCached(), false, stats);
33+
const int Mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()};
34+
35+
struct kinfo_proc *InfoProc;
36+
uptr Len = sizeof(*InfoProc);
37+
uptr Size = Len;
38+
InfoProc = (struct kinfo_proc *)MmapOrDie(Size, "GetMemoryProfile()");
39+
CHECK_EQ(
40+
internal_sysctl(Mib, ARRAY_SIZE(Mib), nullptr, (uptr *)InfoProc, &Len, 0),
41+
0);
42+
cb(0, InfoProc->ki_rssize * GetPageSizeCached(), false, stats);
43+
UnmapOrDie(InfoProc, Size, true);
4444
}
4545
#endif
4646

0 commit comments

Comments
 (0)